mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +00:00
Don't print log messages when testing fee level.
This commit is contained in:
@@ -4,8 +4,6 @@ import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -13,19 +11,19 @@ import java.io.File;
|
||||
* A program that sends a transaction with the specified fee and measures how long it takes to confirm.
|
||||
*/
|
||||
public class TestFeeLevel {
|
||||
private static Logger log = LoggerFactory.getLogger(TestFeeLevel.class);
|
||||
|
||||
public static final MainNetParams PARAMS = MainNetParams.get();
|
||||
private static WalletAppKit kit;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
BriefLogFormatter.init();
|
||||
BriefLogFormatter.initWithSilentBitcoinJ();
|
||||
if (args.length == 0) {
|
||||
System.err.println("Specify the fee level to test in satoshis as the first argument.");
|
||||
return;
|
||||
}
|
||||
|
||||
Coin feeToTest = Coin.valueOf(Long.parseLong(args[0]));
|
||||
System.out.println("Fee to test is " + feeToTest.toFriendlyString());
|
||||
|
||||
kit = new WalletAppKit(PARAMS, new File("."), "testfeelevel");
|
||||
kit.startAsync();
|
||||
@@ -44,26 +42,26 @@ public class TestFeeLevel {
|
||||
final Address address = kit.wallet().currentReceiveKey().toAddress(PARAMS);
|
||||
|
||||
if (kit.wallet().getBalance().compareTo(feeToTest) < 0) {
|
||||
log.info("Send some money to {}", address);
|
||||
log.info("... and wait for it to confirm");
|
||||
System.out.println("Send some money to " + address);
|
||||
System.out.println("... and wait for it to confirm");
|
||||
kit.wallet().getBalanceFuture(feeToTest, Wallet.BalanceType.AVAILABLE).get();
|
||||
}
|
||||
|
||||
int heightAtStart = kit.chain().getBestChainHeight();
|
||||
log.info("Height at start is {}", heightAtStart);
|
||||
System.out.println("Height at start is " + heightAtStart);
|
||||
|
||||
Wallet.SendRequest request = Wallet.SendRequest.to(address, kit.wallet().getBalance().subtract(feeToTest));
|
||||
request.feePerKb = feeToTest;
|
||||
request.ensureMinRequiredFee = false;
|
||||
kit.wallet().completeTx(request);
|
||||
log.info("Fee paid is {}", request.fee);
|
||||
log.info("TX is {}", request.tx);
|
||||
System.out.println("Fee paid is " + request.fee.toFriendlyString());
|
||||
System.out.println("TX is " + request.tx);
|
||||
kit.peerGroup().broadcastTransaction(request.tx).future().get();
|
||||
log.info("Send complete, waiting for confirmation");
|
||||
System.out.println("Send complete, waiting for confirmation");
|
||||
request.tx.getConfidence().getDepthFuture(1).get();
|
||||
|
||||
int heightNow = kit.chain().getBestChainHeight();
|
||||
log.info("Height after confirmation is {}", heightNow);
|
||||
log.info("Result: took {} blocks to confirm at this fee level", heightNow - heightAtStart);
|
||||
System.out.println("Height after confirmation is " + heightNow);
|
||||
System.out.println("Result: took " + (heightNow - heightAtStart) + " blocks to confirm at this fee level");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user