forked from Qortal/qortal
Improve synchronization
This commit is contained in:
parent
4744232a1c
commit
e5b3166df4
@ -212,7 +212,7 @@ public class Controller extends Thread {
|
||||
|
||||
try {
|
||||
while (!isStopping) {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(10000);
|
||||
|
||||
potentiallySynchronize();
|
||||
|
||||
|
@ -69,6 +69,10 @@ public class Synchronizer {
|
||||
this.ourHeight = this.repository.getBlockRepository().getBlockchainHeight();
|
||||
final int peerHeight = peer.getPeerData().getLastHeight();
|
||||
|
||||
// If peer is at genesis block then peer has no blocks so ignore them for a while
|
||||
if (peerHeight == 1)
|
||||
return false;
|
||||
|
||||
LOGGER.info(String.format("Synchronizing with peer %s at height %d, our height %d", peer, peerHeight, this.ourHeight));
|
||||
|
||||
List<byte[]> signatures = findSignaturesFromCommonBlock(peer);
|
||||
@ -83,10 +87,6 @@ public class Synchronizer {
|
||||
LOGGER.info(String.format("Common block with peer %s is at height %d", peer, commonBlockHeight));
|
||||
signatures.remove(0);
|
||||
|
||||
// If common block is genesis block then peer has no blocks so ignore them for a while
|
||||
if (commonBlockHeight == 1)
|
||||
return false;
|
||||
|
||||
// If common block is peer's latest block then we simply have a longer chain to peer, so exit now
|
||||
if (commonBlockHeight == peerHeight)
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user