MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / BlockRequestAllowed

Function BlockRequestAllowed

src/net_processing.cpp:834–841  ·  view source on GitHub ↗

To prevent fingerprinting attacks, only send blocks/headers outside of the active chain if they are no more than a month older (both in time, and in best equivalent proof of work) than the best header chain we know about and we fully-validated them at some point.

Source from the content-addressed store, hash-verified

832// best equivalent proof of work) than the best header chain we know about and
833// we fully-validated them at some point.
834static bool BlockRequestAllowed(const CBlockIndex* pindex, const Consensus::Params& consensusParams)
835{
836 AssertLockHeld(cs_main);
837 if (chainActive.Contains(pindex)) return true;
838 return pindex->IsValid(BLOCK_VALID_SCRIPTS) && (pindexBestHeader != nullptr) &&
839 (pindexBestHeader->GetBlockTime() - pindex->GetBlockTime() < STALE_RELAY_AGE_LIMIT) &&
840 (GetBlockProofEquivalentTime(*pindexBestHeader, *pindex, *pindexBestHeader, consensusParams) < STALE_RELAY_AGE_LIMIT);
841}
842
843PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn, CScheduler &scheduler, bool enable_bip61)
844 : connman(connmanIn), m_stale_tip_check_time(0), m_enable_bip61(enable_bip61) {

Callers 2

ProcessGetBlockDataFunction · 0.85
ProcessMessageFunction · 0.85

Calls 4

ContainsMethod · 0.45
IsValidMethod · 0.45
GetBlockTimeMethod · 0.45

Tested by

no test coverage detected