aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2017-08-14 16:14:19 +0200
committerWladimir J. van der Laan <[email protected]>2017-08-14 16:19:35 +0200
commit0e5cff6f2b57546d767b1cb95486fa1754b45034 (patch)
treebcb21a92d4079a768c67195818b8528dbbb18ace /src/net_processing.cpp
parentMerge #11028: Avoid masking of difficulty adjustment errors by checkpoints (diff)
parentMake sure to clean up mapBlockSource if we've already seen the block (diff)
downloaddiscoin-0e5cff6f2b57546d767b1cb95486fa1754b45034.tar.xz
discoin-0e5cff6f2b57546d767b1cb95486fa1754b45034.zip
Merge #11012: Make sure to clean up mapBlockSource if we've already seen the block
3f8fa7f Make sure to clean up mapBlockSource if we've already seen the block (Cory Fields) Pull request description: Otherwise we may leave them dangling. Credit TheBlueMatt. Tree-SHA512: 8be77e08ebfc4f5b206d5ee7cfbe87f92c1eb5bc2b412471993658fe210306789aaf0f3d1454c635508a7d8effede2cf5ac144d622b0157b872733d9661d65c3
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 6fabfcf0a..6aab13fe1 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2145,9 +2145,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
@@ -2222,8 +2225,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());
+ }
}
}
@@ -2401,8 +2408,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());
+ }
}