diff options
| author | Pieter Wuille <[email protected]> | 2015-04-28 07:42:38 -0700 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2015-04-28 07:46:27 -0700 |
| commit | 7bf5d5efa60c89c0e0c353dddc2a76fe4f243808 (patch) | |
| tree | 3cb358f18cc7642a65472aa19455508d3fefc481 /src/main.cpp | |
| parent | Merge pull request #6054 (diff) | |
| parent | Use equivalent PoW for non-main-chain requests (diff) | |
| download | discoin-7bf5d5efa60c89c0e0c353dddc2a76fe4f243808.tar.xz discoin-7bf5d5efa60c89c0e0c353dddc2a76fe4f243808.zip | |
Merge pull request #5918
f7303f9 Use equivalent PoW for non-main-chain requests (Pieter Wuille)
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index 2c12e0849..e6248c661 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3675,7 +3675,6 @@ bool static AlreadyHave(const CInv& inv) return true; } - void static ProcessGetData(CNode* pfrom) { std::deque<CInv>::iterator it = pfrom->vRecvGetData.begin(); @@ -3703,11 +3702,13 @@ void static ProcessGetData(CNode* pfrom) if (chainActive.Contains(mi->second)) { send = true; } else { + static const int nOneMonth = 30 * 24 * 60 * 60; // To prevent fingerprinting attacks, only send blocks outside of the active - // chain if they are valid, and no more than a month older than the best header - // chain we know about. + // chain if they are valid, and no more than a month older (both in time, and in + // best equivalent proof of work) than the best header chain we know about. send = mi->second->IsValid(BLOCK_VALID_SCRIPTS) && (pindexBestHeader != NULL) && - (mi->second->GetBlockTime() > pindexBestHeader->GetBlockTime() - 30 * 24 * 60 * 60); + (pindexBestHeader->GetBlockTime() - mi->second->GetBlockTime() < nOneMonth) && + (GetBlockProofEquivalentTime(*pindexBestHeader, *mi->second, *pindexBestHeader, Params().GetConsensus()) < nOneMonth); if (!send) { LogPrintf("%s: ignoring request from peer=%i for old block that isn't in the main chain\n", __func__, pfrom->GetId()); } |