forked from Qortal/qortal
Synchronizer improvements & minor fix
Restrict synchronizer to only consider peers at most 60 blocks behind. Synchronizer will only process a batch of 200 blocks at a time. Improve debugging message in Peer.
This commit is contained in:
parent
4b02b7a14f
commit
6feca1f4d6
@ -31,7 +31,8 @@ public class Synchronizer {
|
|||||||
|
|
||||||
private static final int INITIAL_BLOCK_STEP = 8;
|
private static final int INITIAL_BLOCK_STEP = 8;
|
||||||
private static final int MAXIMUM_BLOCK_STEP = 500;
|
private static final int MAXIMUM_BLOCK_STEP = 500;
|
||||||
private static final int MAXIMUM_HEIGHT_DELTA = 2000; // XXX move to blockchain config?
|
private static final int MAXIMUM_HEIGHT_DELTA = 60; // XXX move to blockchain config?
|
||||||
|
private static final int SYNC_BATCH_SIZE = 200;
|
||||||
|
|
||||||
private static Synchronizer instance;
|
private static Synchronizer instance;
|
||||||
|
|
||||||
@ -153,7 +154,7 @@ public class Synchronizer {
|
|||||||
|
|
||||||
// Fetch, and apply, blocks from peer
|
// Fetch, and apply, blocks from peer
|
||||||
byte[] signature = commonBlockData.getSignature();
|
byte[] signature = commonBlockData.getSignature();
|
||||||
while (this.ourHeight < peerHeight) {
|
while (this.ourHeight < peerHeight && this.ourHeight < commonBlockHeight + SYNC_BATCH_SIZE) {
|
||||||
// Do we need more signatures?
|
// Do we need more signatures?
|
||||||
if (signatures.isEmpty()) {
|
if (signatures.isEmpty()) {
|
||||||
signatures = this.getBlockSignatures(peer, signature, MAXIMUM_BLOCK_STEP);
|
signatures = this.getBlockSignatures(peer, signature, MAXIMUM_BLOCK_STEP);
|
||||||
|
@ -317,7 +317,7 @@ public class Peer implements Runnable {
|
|||||||
|
|
||||||
// Close socket
|
// Close socket
|
||||||
if (!this.socket.isClosed()) {
|
if (!this.socket.isClosed()) {
|
||||||
LOGGER.debug(String.format("Disconnected peer %s", this));
|
LOGGER.debug(String.format("Disconnecting peer %s", this));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.socket.close();
|
this.socket.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user