forked from Qortal/qortal
Check "isFastSyncEnabledWhenResolvingFork" setting before requesting multiple blocks from a peer. This allows users to opt out of this functionality, by setting it to false in their settings.
This commit is contained in:
parent
dbcf6de2d5
commit
8c3753326f
@ -34,6 +34,7 @@ import org.qortal.network.message.Message.MessageType;
|
|||||||
import org.qortal.repository.DataException;
|
import org.qortal.repository.DataException;
|
||||||
import org.qortal.repository.Repository;
|
import org.qortal.repository.Repository;
|
||||||
import org.qortal.repository.RepositoryManager;
|
import org.qortal.repository.RepositoryManager;
|
||||||
|
import org.qortal.settings.Settings;
|
||||||
import org.qortal.transaction.Transaction;
|
import org.qortal.transaction.Transaction;
|
||||||
import org.qortal.utils.Base58;
|
import org.qortal.utils.Base58;
|
||||||
|
|
||||||
@ -370,12 +371,11 @@ public class Synchronizer {
|
|||||||
int additionalPeerBlocksAfterCommonBlock = peerHeight - commonBlockHeight;
|
int additionalPeerBlocksAfterCommonBlock = peerHeight - commonBlockHeight;
|
||||||
|
|
||||||
|
|
||||||
// Firstly, attempt to retrieve the blocks themselves, rather than signatures. This is supported by newer peers.
|
// Firstly, attempt to retrieve the blocks themselves, rather than signatures. This is supported by newer peers (version 1.5.0 and above).
|
||||||
// We could optionally check for a version here if we didn't want to make unnecessary requests
|
|
||||||
List<Block> peerBlocks = new ArrayList<>();
|
List<Block> peerBlocks = new ArrayList<>();
|
||||||
|
|
||||||
if (peer.getPeersVersion() >= PEER_VERSION_150) {
|
if (Settings.getInstance().isFastSyncEnabledWhenResolvingFork() && peer.getPeersVersion() >= PEER_VERSION_150) {
|
||||||
// This peer supports syncing multiple blocks at once via GetBlocksMessage
|
// This peer supports syncing multiple blocks at once via GetBlocksMessage, and it is enabled in the settings
|
||||||
int numberBlocksRequired = additionalPeerBlocksAfterCommonBlock - peerBlocks.size();
|
int numberBlocksRequired = additionalPeerBlocksAfterCommonBlock - peerBlocks.size();
|
||||||
while (numberBlocksRequired > 0) {
|
while (numberBlocksRequired > 0) {
|
||||||
if (Controller.isStopping())
|
if (Controller.isStopping())
|
||||||
@ -422,7 +422,7 @@ public class Synchronizer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Older peer version - use slow sync
|
// Older peer version, or fast sync is disabled in the settings - use slow sync
|
||||||
|
|
||||||
// Convert any leftover (post-common) block summaries into signatures to request from peer
|
// Convert any leftover (post-common) block summaries into signatures to request from peer
|
||||||
List<byte[]> peerBlockSignatures = peerBlockSummaries.stream().map(BlockSummaryData::getSignature).collect(Collectors.toList());
|
List<byte[]> peerBlockSignatures = peerBlockSummaries.stream().map(BlockSummaryData::getSignature).collect(Collectors.toList());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user