aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorShibe <[email protected]>2021-02-08 04:54:51 +0400
committerShibe <[email protected]>2021-02-08 16:52:55 +0400
commitef9242b9ec46a28690e49debe2c2364bb70be702 (patch)
treeb012eaa7e97e3ae70d99027ec5e31f3d08febc20 /src/validation.cpp
parentMerge pull request #1705 from rnicoll/block-download-timeout (diff)
downloaddiscoin-ef9242b9ec46a28690e49debe2c2364bb70be702.tar.xz
discoin-ef9242b9ec46a28690e49debe2c2364bb70be702.zip
Don't re-check AuxPoW when sending data to peers
Checking scrypt PoW is expensive and needless in this case. All block headers are already checked when they are accepted, and they will be checked again on the receiving end.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 3ddf67717..c5f00fe13 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1142,7 +1142,7 @@ bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHea
both a block and its header. */
template<typename T>
-static bool ReadBlockOrHeader(T& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams)
+static bool ReadBlockOrHeader(T& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams, bool fCheckPOW)
{
block.SetNull();
@@ -1160,16 +1160,16 @@ static bool ReadBlockOrHeader(T& block, const CDiskBlockPos& pos, const Consensu
}
// Check the header
- if (!CheckAuxPowProofOfWork(block, consensusParams))
+ if (fCheckPOW && !CheckAuxPowProofOfWork(block, consensusParams))
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
return true;
}
template<typename T>
-static bool ReadBlockOrHeader(T& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
+static bool ReadBlockOrHeader(T& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams, bool fCheckPOW)
{
- if (!ReadBlockOrHeader(block, pindex->GetBlockPos(), consensusParams))
+ if (!ReadBlockOrHeader(block, pindex->GetBlockPos(), consensusParams, fCheckPOW))
return false;
if (block.GetHash() != pindex->GetBlockHash())
return error("ReadBlockOrHeader(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
@@ -1177,19 +1177,19 @@ static bool ReadBlockOrHeader(T& block, const CBlockIndex* pindex, const Consens
return true;
}
-bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams)
+bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams, bool fCheckPOW)
{
- return ReadBlockOrHeader(block, pos, consensusParams);
+ return ReadBlockOrHeader(block, pos, consensusParams, fCheckPOW);
}
-bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
+bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams, bool fCheckPOW)
{
- return ReadBlockOrHeader(block, pindex, consensusParams);
+ return ReadBlockOrHeader(block, pindex, consensusParams, fCheckPOW);
}
-bool ReadBlockHeaderFromDisk(CBlockHeader& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
+bool ReadBlockHeaderFromDisk(CBlockHeader& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams, bool fCheckPOW)
{
- return ReadBlockOrHeader(block, pindex, consensusParams);
+ return ReadBlockOrHeader(block, pindex, consensusParams, fCheckPOW);
}
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)