mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-17 18:40:09 +00:00
Push down cs_main locking in ProcessMessage
This commit is contained in:
parent
49d754d915
commit
7d38af3c49
23
src/main.cpp
23
src/main.cpp
@ -3278,6 +3278,8 @@ void static ProcessGetData(CNode* pfrom)
|
|||||||
|
|
||||||
vector<CInv> vNotFound;
|
vector<CInv> vNotFound;
|
||||||
|
|
||||||
|
LOCK(cs_main);
|
||||||
|
|
||||||
while (it != pfrom->vRecvGetData.end()) {
|
while (it != pfrom->vRecvGetData.end()) {
|
||||||
// Don't bother if send buffer is too full to respond anyway
|
// Don't bother if send buffer is too full to respond anyway
|
||||||
if (pfrom->nSendSize >= SendBufferSize())
|
if (pfrom->nSendSize >= SendBufferSize())
|
||||||
@ -3450,7 +3452,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
|
|
||||||
pfrom->fClient = !(pfrom->nServices & NODE_NETWORK);
|
pfrom->fClient = !(pfrom->nServices & NODE_NETWORK);
|
||||||
|
|
||||||
AddTimeData(pfrom->addr, nTime);
|
|
||||||
|
|
||||||
// Change version
|
// Change version
|
||||||
pfrom->PushMessage("verack");
|
pfrom->PushMessage("verack");
|
||||||
@ -3492,6 +3493,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
|
|
||||||
LogPrintf("receive version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString().c_str(), addrFrom.ToString().c_str(), pfrom->addr.ToString().c_str());
|
LogPrintf("receive version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString().c_str(), addrFrom.ToString().c_str(), pfrom->addr.ToString().c_str());
|
||||||
|
|
||||||
|
LOCK(cs_main);
|
||||||
|
AddTimeData(pfrom->addr, nTime);
|
||||||
cPeerBlockCounts.input(pfrom->nStartingHeight);
|
cPeerBlockCounts.input(pfrom->nStartingHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3595,6 +3598,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOCK(cs_main);
|
||||||
|
|
||||||
for (unsigned int nInv = 0; nInv < vInv.size(); nInv++)
|
for (unsigned int nInv = 0; nInv < vInv.size(); nInv++)
|
||||||
{
|
{
|
||||||
const CInv &inv = vInv[nInv];
|
const CInv &inv = vInv[nInv];
|
||||||
@ -3652,6 +3658,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
uint256 hashStop;
|
uint256 hashStop;
|
||||||
vRecv >> locator >> hashStop;
|
vRecv >> locator >> hashStop;
|
||||||
|
|
||||||
|
LOCK(cs_main);
|
||||||
|
|
||||||
// Find the last block the caller has in the main chain
|
// Find the last block the caller has in the main chain
|
||||||
CBlockIndex* pindex = locator.GetBlockIndex();
|
CBlockIndex* pindex = locator.GetBlockIndex();
|
||||||
|
|
||||||
@ -3686,6 +3694,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
uint256 hashStop;
|
uint256 hashStop;
|
||||||
vRecv >> locator >> hashStop;
|
vRecv >> locator >> hashStop;
|
||||||
|
|
||||||
|
LOCK(cs_main);
|
||||||
|
|
||||||
CBlockIndex* pindex = NULL;
|
CBlockIndex* pindex = NULL;
|
||||||
if (locator.IsNull())
|
if (locator.IsNull())
|
||||||
{
|
{
|
||||||
@ -3728,6 +3738,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
CInv inv(MSG_TX, tx.GetHash());
|
CInv inv(MSG_TX, tx.GetHash());
|
||||||
pfrom->AddInventoryKnown(inv);
|
pfrom->AddInventoryKnown(inv);
|
||||||
|
|
||||||
|
LOCK(cs_main);
|
||||||
|
|
||||||
bool fMissingInputs = false;
|
bool fMissingInputs = false;
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
if (mempool.accept(state, tx, true, &fMissingInputs))
|
if (mempool.accept(state, tx, true, &fMissingInputs))
|
||||||
@ -3802,6 +3814,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
CInv inv(MSG_BLOCK, block.GetHash());
|
CInv inv(MSG_BLOCK, block.GetHash());
|
||||||
pfrom->AddInventoryKnown(inv);
|
pfrom->AddInventoryKnown(inv);
|
||||||
|
|
||||||
|
LOCK(cs_main);
|
||||||
|
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
if (ProcessBlock(state, pfrom, &block))
|
if (ProcessBlock(state, pfrom, &block))
|
||||||
mapAlreadyAskedFor.erase(inv);
|
mapAlreadyAskedFor.erase(inv);
|
||||||
@ -3823,6 +3837,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
|
|
||||||
else if (strCommand == "mempool")
|
else if (strCommand == "mempool")
|
||||||
{
|
{
|
||||||
|
LOCK(cs_main);
|
||||||
|
|
||||||
std::vector<uint256> vtxid;
|
std::vector<uint256> vtxid;
|
||||||
LOCK2(mempool.cs, pfrom->cs_filter);
|
LOCK2(mempool.cs, pfrom->cs_filter);
|
||||||
mempool.queryHashes(vtxid);
|
mempool.queryHashes(vtxid);
|
||||||
@ -4088,10 +4104,7 @@ bool ProcessMessages(CNode* pfrom)
|
|||||||
bool fRet = false;
|
bool fRet = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
{
|
fRet = ProcessMessage(pfrom, strCommand, vRecv);
|
||||||
LOCK(cs_main);
|
|
||||||
fRet = ProcessMessage(pfrom, strCommand, vRecv);
|
|
||||||
}
|
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
}
|
}
|
||||||
catch (std::ios_base::failure& e)
|
catch (std::ios_base::failure& e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user