mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 07:12:17 +00:00
WalletTool: allow control of logging from the command line. Change how block chain download is waited for.
This commit is contained in:
parent
11dcb0a682
commit
cfd06195a0
@ -20,6 +20,7 @@ import com.google.bitcoin.core.*;
|
||||
import com.google.bitcoin.discovery.DnsDiscovery;
|
||||
import com.google.bitcoin.store.BlockStoreException;
|
||||
import com.google.bitcoin.store.BoundedOverheadBlockStore;
|
||||
import com.google.bitcoin.utils.BriefLogFormatter;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
@ -84,12 +85,10 @@ public class WalletTool {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// Disable logspam.
|
||||
LogManager.getLogManager().getLogger("").setLevel(Level.SEVERE);
|
||||
|
||||
OptionParser parser = new OptionParser();
|
||||
parser.accepts("help");
|
||||
parser.accepts("force");
|
||||
parser.accepts("debuglog");
|
||||
walletFileName = parser.accepts("wallet")
|
||||
.withRequiredArg()
|
||||
.defaultsTo("wallet");
|
||||
@ -116,6 +115,13 @@ public class WalletTool {
|
||||
System.out.println(HELP_TEXT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.has("debuglog")) {
|
||||
BriefLogFormatter.init();
|
||||
} else {
|
||||
// Disable logspam unless there is a flag.
|
||||
LogManager.getLogManager().getLogger("").setLevel(Level.SEVERE);
|
||||
}
|
||||
|
||||
File chainFileName;
|
||||
switch (netFlag.value(options)) {
|
||||
@ -187,17 +193,19 @@ public class WalletTool {
|
||||
final int startTransactions = wallet.getTransactions(true, true).size();
|
||||
|
||||
peers.start();
|
||||
peers.startBlockChainDownload(new DownloadListener() {
|
||||
@Override
|
||||
protected void doneDownload() {
|
||||
super.doneDownload();
|
||||
peers.stop();
|
||||
int endTransactions = wallet.getTransactions(true, true).size();
|
||||
if (endTransactions > startTransactions) {
|
||||
System.out.println("Synced " + (endTransactions - startTransactions) + " transactions.");
|
||||
}
|
||||
}
|
||||
});
|
||||
DownloadListener listener = new DownloadListener();
|
||||
peers.startBlockChainDownload(listener);
|
||||
try {
|
||||
listener.await();
|
||||
} catch (InterruptedException e) {
|
||||
System.err.println("Chain download interrupted, quitting ...");
|
||||
System.exit(1);
|
||||
}
|
||||
peers.stop();
|
||||
int endTransactions = wallet.getTransactions(true, true).size();
|
||||
if (endTransactions > startTransactions) {
|
||||
System.out.println("Synced " + (endTransactions - startTransactions) + " transactions.");
|
||||
}
|
||||
} catch (BlockStoreException e) {
|
||||
System.err.println("Error reading block chain file " + chainFileName + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user