@@ -1782,11 +1782,19 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1782
1782
}
1783
1783
}
1784
1784
1785
+ // When we succeed in decoding a block's txids from a cmpctblock
1786
+ // message we typically jump to the BLOCKTXN handling code, with a
1787
+ // dummy (empty) BLOCKTXN message, to re-use the logic there in
1788
+ // completing processing of the putative block (without cs_main).
1789
+ bool fProcessBLOCKTXN = false ;
1790
+ CDataStream blockTxnMsg (SER_NETWORK, PROTOCOL_VERSION);
1791
+
1785
1792
// Keep a CBlock for "optimistic" compactblock reconstructions (see
1786
1793
// below)
1787
1794
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
1788
1795
bool fBlockReconstructed = false ;
1789
1796
1797
+ {
1790
1798
LOCK (cs_main);
1791
1799
// If AcceptBlockHeader returned true, it set pindex
1792
1800
assert (pindex);
@@ -1868,9 +1876,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1868
1876
// Dirty hack to jump to BLOCKTXN code (TODO: move message handling into their own functions)
1869
1877
BlockTransactions txn;
1870
1878
txn.blockhash = cmpctblock.header .GetHash ();
1871
- CDataStream blockTxnMsg (SER_NETWORK, PROTOCOL_VERSION);
1872
1879
blockTxnMsg << txn;
1873
- return ProcessMessage (pfrom, NetMsgType::BLOCKTXN, blockTxnMsg, nTimeReceived, chainparams, connman) ;
1880
+ fProcessBLOCKTXN = true ;
1874
1881
} else {
1875
1882
req.blockhash = pindex->GetBlockHash ();
1876
1883
connman.PushMessage (pfrom, msgMaker.Make (NetMsgType::GETBLOCKTXN, req));
@@ -1911,6 +1918,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1911
1918
return ProcessMessage (pfrom, NetMsgType::HEADERS, vHeadersMsg, nTimeReceived, chainparams, connman);
1912
1919
}
1913
1920
}
1921
+ } // cs_main
1922
+
1923
+ if (fProcessBLOCKTXN )
1924
+ return ProcessMessage (pfrom, NetMsgType::BLOCKTXN, blockTxnMsg, nTimeReceived, chainparams, connman);
1914
1925
1915
1926
if (fBlockReconstructed ) {
1916
1927
// If we got here, we were able to optimistically reconstruct a
0 commit comments