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.
| 832 | // best equivalent proof of work) than the best header chain we know about and |
| 833 | // we fully-validated them at some point. |
| 834 | static 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 | |
| 843 | PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn, CScheduler &scheduler, bool enable_bip61) |
| 844 | : connman(connmanIn), m_stale_tip_check_time(0), m_enable_bip61(enable_bip61) { |
no test coverage detected