mirror of
https://github.com/Qortal/qortal.git
synced 2025-05-08 18:57:52 +00:00
Improve synchronization
This commit is contained in:
parent
4744232a1c
commit
e5b3166df4
@ -212,7 +212,7 @@ public class Controller extends Thread {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
while (!isStopping) {
|
while (!isStopping) {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(10000);
|
||||||
|
|
||||||
potentiallySynchronize();
|
potentiallySynchronize();
|
||||||
|
|
||||||
|
@ -69,6 +69,10 @@ public class Synchronizer {
|
|||||||
this.ourHeight = this.repository.getBlockRepository().getBlockchainHeight();
|
this.ourHeight = this.repository.getBlockRepository().getBlockchainHeight();
|
||||||
final int peerHeight = peer.getPeerData().getLastHeight();
|
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));
|
LOGGER.info(String.format("Synchronizing with peer %s at height %d, our height %d", peer, peerHeight, this.ourHeight));
|
||||||
|
|
||||||
List<byte[]> signatures = findSignaturesFromCommonBlock(peer);
|
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));
|
LOGGER.info(String.format("Common block with peer %s is at height %d", peer, commonBlockHeight));
|
||||||
signatures.remove(0);
|
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 common block is peer's latest block then we simply have a longer chain to peer, so exit now
|
||||||
if (commonBlockHeight == peerHeight)
|
if (commonBlockHeight == peerHeight)
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user