From ef9242b9ec46a28690e49debe2c2364bb70be702 Mon Sep 17 00:00:00 2001 From: Shibe Date: Mon, 8 Feb 2021 04:54:51 +0400 Subject: 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. --- src/net_processing.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/net_processing.cpp') diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 1a918f486..1b33d529b 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1037,7 +1037,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam { // Send block from disk CBlock block; - if (!ReadBlockFromDisk(block, (*mi).second, consensusParams)) + if (!ReadBlockFromDisk(block, (*mi).second, consensusParams, false)) assert(!"cannot load block from disk"); if (inv.type == MSG_BLOCK) connman.PushMessage(pfrom, msgMaker.Make(SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::BLOCK, block)); @@ -1705,7 +1705,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr } CBlock block; - bool ret = ReadBlockFromDisk(block, it->second, chainparams.GetConsensus(it->second->nHeight)); + bool ret = ReadBlockFromDisk(block, it->second, chainparams.GetConsensus(it->second->nHeight), false); assert(ret); SendBlockTransactions(block, req, pfrom, connman); @@ -1748,7 +1748,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr LogPrint("net", "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), pfrom->id); for (; pindex; pindex = chainActive.Next(pindex)) { - vHeaders.push_back(pindex->GetBlockHeader(chainparams.GetConsensus(pindex->nHeight))); + vHeaders.push_back(pindex->GetBlockHeader(chainparams.GetConsensus(pindex->nHeight), false)); if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop) break; } @@ -2974,14 +2974,14 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic& interr pBestIndex = pindex; if (fFoundStartingHeader) { // add this to the headers message - vHeaders.push_back(pindex->GetBlockHeader(consensusParams)); + vHeaders.push_back(pindex->GetBlockHeader(consensusParams, false)); } else if (PeerHasHeader(&state, pindex)) { continue; // keep looking for the first new block } else if (pindex->pprev == NULL || PeerHasHeader(&state, pindex->pprev)) { // Peer doesn't have this header but they do have the prior one. // Start sending headers. fFoundStartingHeader = true; - vHeaders.push_back(pindex->GetBlockHeader(consensusParams)); + vHeaders.push_back(pindex->GetBlockHeader(consensusParams, false)); } else { // Peer doesn't have this header or the prior one -- nothing will // connect, so bail out. @@ -3014,7 +3014,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic& interr } if (!fGotBlockFromCache) { CBlock block; - bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams); + bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams, false); assert(ret); CBlockHeaderAndShortTxIDs cmpctblock(block, state.fWantsCmpctWitness); connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock)); -- cgit v1.2.3