diff options
author | Matt Corallo <git@bluematt.me> | 2016-11-03 16:34:31 -0400 |
---|---|---|
committer | Matt Corallo <git@bluematt.me> | 2016-11-23 16:29:38 -0800 |
commit | 63fd101c529cf6e2bc5ecab244fd56e2c5be521f (patch) | |
tree | 80ee584fb960fcc26435dab0b247243adfa21145 /src | |
parent | 4a6b1f36b773001f6c5a8e1d3d196833e4fb872d (diff) |
Split ::HEADERS processing into two separate cs_main locks
This will allow NotifyHeaderTip to be called from an
AcceptBlockHeader wrapper function without holding cs_main.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index 4a2682bc78..4cd5bebb7c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5982,14 +5982,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, ReadCompactSize(vRecv); // ignore tx count; assume it is 0. } - { - LOCK(cs_main); - if (nCount == 0) { // Nothing interesting. Stop asking this peers for more headers. return true; } + CBlockIndex *pindexLast = NULL; + { + LOCK(cs_main); CNodeState *nodestate = State(pfrom->GetId()); // If this looks like it could be a block announcement (nCount < @@ -6019,7 +6019,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } - CBlockIndex *pindexLast = NULL; BOOST_FOREACH(const CBlockHeader& header, headers) { CValidationState state; if (pindexLast != NULL && header.hashPrevBlock != pindexLast->GetBlockHash()) { @@ -6035,7 +6034,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } } + } + { + LOCK(cs_main); + CNodeState *nodestate = State(pfrom->GetId()); if (nodestate->nUnconnectingHeaders > 0) { LogPrint("net", "peer=%d: resetting nUnconnectingHeaders (%d -> 0)\n", pfrom->id, nodestate->nUnconnectingHeaders); } |