Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,275 Lines • ▼ Show 20 Lines | bool need_activate_chain = false; | ||||
// in the unlock of cs_main before ActivateBestChain but after | // in the unlock of cs_main before ActivateBestChain but after | ||||
// AcceptBlock). In this case, we need to run ActivateBestChain | // AcceptBlock). In this case, we need to run ActivateBestChain | ||||
// prior to checking the relay conditions below. | // prior to checking the relay conditions below. | ||||
need_activate_chain = true; | need_activate_chain = true; | ||||
} | } | ||||
} | } | ||||
} // release cs_main before calling ActivateBestChain | } // release cs_main before calling ActivateBestChain | ||||
if (need_activate_chain) { | if (need_activate_chain) { | ||||
CValidationState dummy; | CValidationState state; | ||||
ActivateBestChain(config, dummy, a_recent_block); | if (!ActivateBestChain(config, state, a_recent_block)) { | ||||
LogPrint(BCLog::NET, "failed to activate chain (%s)\n", | |||||
FormatStateMessage(state)); | |||||
} | |||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const CBlockIndex *pindex = LookupBlockIndex(inv.hash); | const CBlockIndex *pindex = LookupBlockIndex(inv.hash); | ||||
if (pindex) { | if (pindex) { | ||||
send = BlockRequestAllowed(pindex, consensusParams); | send = BlockRequestAllowed(pindex, consensusParams); | ||||
if (!send) { | if (!send) { | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
▲ Show 20 Lines • Show All 986 Lines • ▼ Show 20 Lines | else if (strCommand == NetMsgType::GETBLOCKS) { | ||||
// for getheaders requests, and there are no known nodes which support | // for getheaders requests, and there are no known nodes which support | ||||
// compact blocks but still use getblocks to request blocks. | // compact blocks but still use getblocks to request blocks. | ||||
{ | { | ||||
std::shared_ptr<const CBlock> a_recent_block; | std::shared_ptr<const CBlock> a_recent_block; | ||||
{ | { | ||||
LOCK(cs_most_recent_block); | LOCK(cs_most_recent_block); | ||||
a_recent_block = most_recent_block; | a_recent_block = most_recent_block; | ||||
} | } | ||||
CValidationState dummy; | CValidationState state; | ||||
ActivateBestChain(config, dummy, a_recent_block); | if (!ActivateBestChain(config, state, a_recent_block)) { | ||||
LogPrint(BCLog::NET, "failed to activate chain (%s)\n", | |||||
FormatStateMessage(state)); | |||||
} | |||||
} | } | ||||
LOCK(cs_main); | 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 | ||||
const CBlockIndex *pindex = FindForkInGlobalIndex(chainActive, locator); | const CBlockIndex *pindex = FindForkInGlobalIndex(chainActive, locator); | ||||
// Send the rest of the chain | // Send the rest of the chain | ||||
▲ Show 20 Lines • Show All 2,075 Lines • Show Last 20 Lines |