diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2017-08-08 21:44:02 -0400 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2017-08-08 21:45:18 -0400 |
commit | 3f8fa7f58b68a8ed596c62d1edb85a3455a5a724 (patch) | |
tree | c7be1851a65906c6ba93ec3e33170c8486724a75 /src | |
parent | e222618a32a16cf0efae392e6349c10c38e57db6 (diff) |
Make sure to clean up mapBlockSource if we've already seen the block
Credit TheBlueMatt
Diffstat (limited to 'src')
-rw-r--r-- | src/net_processing.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index a743f04dd1..4e63cd1a75 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2134,9 +2134,12 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr } bool fNewBlock = false; ProcessNewBlock(chainparams, pblock, true, &fNewBlock); - if (fNewBlock) + if (fNewBlock) { pfrom->nLastBlockTime = GetTime(); - + } else { + LOCK(cs_main); + mapBlockSource.erase(pblock->GetHash()); + } LOCK(cs_main); // hold cs_main for CBlockIndex::IsValid() if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS)) { // Clear download state for this block, which is in @@ -2211,8 +2214,12 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr // Since we requested this block (it was in mapBlocksInFlight), force it to be processed, // even if it would not be a candidate for new tip (missing previous block, chain not long enough, etc) ProcessNewBlock(chainparams, pblock, true, &fNewBlock); - if (fNewBlock) + if (fNewBlock) { pfrom->nLastBlockTime = GetTime(); + } else { + LOCK(cs_main); + mapBlockSource.erase(pblock->GetHash()); + } } } @@ -2390,8 +2397,12 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr } bool fNewBlock = false; ProcessNewBlock(chainparams, pblock, forceProcessing, &fNewBlock); - if (fNewBlock) + if (fNewBlock) { pfrom->nLastBlockTime = GetTime(); + } else { + LOCK(cs_main); + mapBlockSource.erase(pblock->GetHash()); + } } |