mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-18 13:22:42 +01:00
ForwardingService: don't wait for blockchain synchronization before entering RUNNING state
This will speed up synchronization because the .setMaxConnections() call will occur before synchronization is finished and the necessary number of Peers will be found sooner. Also IMO this a better example because most apps should not block while syncing the chain.
This commit is contained in:
parent
6be2fd4999
commit
62fecfa37c
@ -125,9 +125,9 @@ public class ForwardingService implements AutoCloseable {
|
||||
kit.connectToLocalHost();
|
||||
}
|
||||
|
||||
// Download the blockchain and wait until it's done.
|
||||
kit.startAsync();
|
||||
kit.awaitRunning();
|
||||
kit.setBlockingStartup(false); // Don't wait for blockchain synchronization before entering RUNNING state
|
||||
kit.startAsync(); // Connect to the network and start downloading transactions
|
||||
kit.awaitRunning(); // Wait for the service to reach the RUNNING state
|
||||
kit.peerGroup().setMaxConnections(MAX_CONNECTIONS);
|
||||
|
||||
// Start listening and forwarding
|
||||
|
Loading…
Reference in New Issue
Block a user