diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2016-12-01 10:27:12 -0500 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2016-12-26 05:34:54 -0500 |
commit | bd02bddb938fa7ddf4e5dc7c3ce2a787feba848a (patch) | |
tree | 4abdba7ee15d678da5a96f873a425ac7532e9b6f | |
parent | 680b0c0138243c1e48c09a891a926b778388b587 (diff) |
Release cs_main before processing cmpctblock as header
-rw-r--r-- | src/net_processing.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 8a2c35cf3f..1667863336 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1789,6 +1789,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, bool fProcessBLOCKTXN = false; CDataStream blockTxnMsg(SER_NETWORK, PROTOCOL_VERSION); + // If we end up treating this as a plain headers message, call that as well + // without cs_main. + bool fRevertToHeaderProcessing = false; + CDataStream vHeadersMsg(SER_NETWORK, PROTOCOL_VERSION); + // Keep a CBlock for "optimistic" compactblock reconstructions (see // below) std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(); @@ -1913,9 +1918,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // Dirty hack to process as if it were just a headers message (TODO: move message handling into their own functions) std::vector<CBlock> headers; headers.push_back(cmpctblock.header); - CDataStream vHeadersMsg(SER_NETWORK, PROTOCOL_VERSION); vHeadersMsg << headers; - return ProcessMessage(pfrom, NetMsgType::HEADERS, vHeadersMsg, nTimeReceived, chainparams, connman); + fRevertToHeaderProcessing = true; } } } // cs_main @@ -1923,6 +1927,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (fProcessBLOCKTXN) return ProcessMessage(pfrom, NetMsgType::BLOCKTXN, blockTxnMsg, nTimeReceived, chainparams, connman); + if (fRevertToHeaderProcessing) + return ProcessMessage(pfrom, NetMsgType::HEADERS, vHeadersMsg, nTimeReceived, chainparams, connman); + if (fBlockReconstructed) { // If we got here, we were able to optimistically reconstruct a // block that is in flight from some other peer. |