From f7b0fb0008aca98c25ba33ed638fdf0c562c3b80 Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Wed, 27 Mar 2019 00:38:30 -0700 Subject: [PATCH] Increased block download timeout for RegTest as CN hashing is slower and take more time. Fixed deserialization of cn header in python test framework. --- src/net_processing.cpp | 4 +++- test/functional/test_framework/messages.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 7d17147ca..f11affbd1 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3561,7 +3561,9 @@ bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic& interruptM if (state.vBlocksInFlight.size() > 0) { QueuedBlock &queuedBlock = state.vBlocksInFlight.front(); int nOtherPeersWithValidatedDownloads = nPeersWithValidatedDownloads - (state.nBlocksInFlightValidHeaders > 0); - if (nNow > state.nDownloadingSince + consensusParams.nPowTargetSpacing * (BLOCK_DOWNLOAD_TIMEOUT_BASE + BLOCK_DOWNLOAD_TIMEOUT_PER_PEER * nOtherPeersWithValidatedDownloads)) { + // Increase the block downloading timeout for RegTest, as Cryptonight hashing takes more time. + int64_t powTargetSpacing = (consensusParams.nPowTargetSpacing == 20) ? 40 : consensusParams.nPowTargetSpacing; + if (nNow > state.nDownloadingSince + powTargetSpacing * (BLOCK_DOWNLOAD_TIMEOUT_BASE + BLOCK_DOWNLOAD_TIMEOUT_PER_PEER * nOtherPeersWithValidatedDownloads)) { LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", queuedBlock.hash.ToString(), pto->GetId()); pto->fDisconnect = true; return true; diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 951d2483d..a072682ee 100644 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -570,7 +570,8 @@ class CBlockHeader(): self.nNonce = struct.unpack("