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