Browse Source

Increased block download timeout for RegTest as CN hashing is slower and take more time.

Fixed deserialization of cn header in python test framework.
cn_mining
Jianping Wu 6 years ago
parent
commit
f7b0fb0008
  1. 4
      src/net_processing.cpp
  2. 5
      test/functional/test_framework/messages.py

4
src/net_processing.cpp

@ -3561,7 +3561,9 @@ bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& interruptM @@ -3561,7 +3561,9 @@ bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& 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;

5
test/functional/test_framework/messages.py

@ -570,7 +570,8 @@ class CBlockHeader(): @@ -570,7 +570,8 @@ class CBlockHeader():
self.nNonce = struct.unpack("<I", f.read(4))[0]
# Cryptonote header
cnHeader = deser_string(f)
# Skip the length value
deser_compact_size(f)
self.major_version = struct.unpack("<B", f.read(1))[0]
self.minor_version = struct.unpack("<B", f.read(1))[0]
self.timestamp = deser_varint(f)
@ -637,7 +638,7 @@ class CBlockHeader(): @@ -637,7 +638,7 @@ class CBlockHeader():
# self.sha256 stores the cn_fast hash.
self.sha256 = uint256_from_str(pycryptonight.cn_fast_hash(c))
self.hash = encode(pycryptonight.cn_fast_hash(c)[::-1], 'hex_codec').decode('ascii')
# 4 is variant 4. nNonce is used to store block height.
# nNonce is used to store block height.
self.scrypt256 = uint256_from_str(pycryptonight.cn_slow_hash(c, self.major_version - 6, 0, self.nNonce))
def rehash(self):

Loading…
Cancel
Save