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:
Sean Gilligan 2022-07-27 14:59:00 -07:00 committed by Andreas Schildbach
parent 6be2fd4999
commit 62fecfa37c

View File

@ -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