mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-08-28 23:42:07 +00:00
Increased block download timeout for RegTest as CN hashing is slower and take more time.
Fixed deserialization of cn header in python test framework.
This commit is contained in:
parent
dea50be56b
commit
f7b0fb0008
@ -3561,7 +3561,9 @@ bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& interruptM
|
|||||||
if (state.vBlocksInFlight.size() > 0) {
|
if (state.vBlocksInFlight.size() > 0) {
|
||||||
QueuedBlock &queuedBlock = state.vBlocksInFlight.front();
|
QueuedBlock &queuedBlock = state.vBlocksInFlight.front();
|
||||||
int nOtherPeersWithValidatedDownloads = nPeersWithValidatedDownloads - (state.nBlocksInFlightValidHeaders > 0);
|
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());
|
LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", queuedBlock.hash.ToString(), pto->GetId());
|
||||||
pto->fDisconnect = true;
|
pto->fDisconnect = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -570,7 +570,8 @@ class CBlockHeader():
|
|||||||
self.nNonce = struct.unpack("<I", f.read(4))[0]
|
self.nNonce = struct.unpack("<I", f.read(4))[0]
|
||||||
|
|
||||||
# Cryptonote header
|
# 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.major_version = struct.unpack("<B", f.read(1))[0]
|
||||||
self.minor_version = struct.unpack("<B", f.read(1))[0]
|
self.minor_version = struct.unpack("<B", f.read(1))[0]
|
||||||
self.timestamp = deser_varint(f)
|
self.timestamp = deser_varint(f)
|
||||||
@ -637,7 +638,7 @@ class CBlockHeader():
|
|||||||
# self.sha256 stores the cn_fast hash.
|
# self.sha256 stores the cn_fast hash.
|
||||||
self.sha256 = uint256_from_str(pycryptonight.cn_fast_hash(c))
|
self.sha256 = uint256_from_str(pycryptonight.cn_fast_hash(c))
|
||||||
self.hash = encode(pycryptonight.cn_fast_hash(c)[::-1], 'hex_codec').decode('ascii')
|
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))
|
self.scrypt256 = uint256_from_str(pycryptonight.cn_slow_hash(c, self.major_version - 6, 0, self.nNonce))
|
||||||
|
|
||||||
def rehash(self):
|
def rehash(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user