Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,068 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, | void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, | ||||
const CBlockIndex *pindexFork, | const CBlockIndex *pindexFork, | ||||
bool fInitialDownload) { | bool fInitialDownload) { | ||||
const int nNewHeight = pindexNew->nHeight; | const int nNewHeight = pindexNew->nHeight; | ||||
connman->SetBestHeight(nNewHeight); | connman->SetBestHeight(nNewHeight); | ||||
SetServiceFlagsIBDCache(!fInitialDownload); | |||||
if (!fInitialDownload) { | if (!fInitialDownload) { | ||||
// Find the hashes of all blocks that weren't previously in the best | // Find the hashes of all blocks that weren't previously in the best | ||||
// chain. | // chain. | ||||
std::vector<uint256> vHashes; | std::vector<uint256> vHashes; | ||||
const CBlockIndex *pindexToAnnounce = pindexNew; | const CBlockIndex *pindexToAnnounce = pindexNew; | ||||
while (pindexToAnnounce != pindexFork) { | while (pindexToAnnounce != pindexFork) { | ||||
vHashes.push_back(pindexToAnnounce->GetBlockHash()); | vHashes.push_back(pindexToAnnounce->GetBlockHash()); | ||||
pindexToAnnounce = pindexToAnnounce->pprev; | pindexToAnnounce = pindexToAnnounce->pprev; | ||||
▲ Show 20 Lines • Show All 822 Lines • ▼ Show 20 Lines | else if (strCommand == NetMsgType::VERSION) { | ||||
pfrom->nServices = nServices; | pfrom->nServices = nServices; | ||||
pfrom->SetAddrLocal(addrMe); | pfrom->SetAddrLocal(addrMe); | ||||
{ | { | ||||
LOCK(pfrom->cs_SubVer); | LOCK(pfrom->cs_SubVer); | ||||
pfrom->strSubVer = strSubVer; | pfrom->strSubVer = strSubVer; | ||||
pfrom->cleanSubVer = cleanSubVer; | pfrom->cleanSubVer = cleanSubVer; | ||||
} | } | ||||
pfrom->nStartingHeight = nStartingHeight; | pfrom->nStartingHeight = nStartingHeight; | ||||
pfrom->fClient = !(nServices & NODE_NETWORK); | |||||
// set nodes not relaying blocks and tx and not serving (parts) of the | |||||
// historical blockchain as "clients" | |||||
pfrom->fClient = (!(nServices & NODE_NETWORK) && | |||||
!(nServices & NODE_NETWORK_LIMITED)); | |||||
// set nodes not capable of serving the complete blockchain history as | |||||
// "limited nodes" | |||||
pfrom->m_limited_node = | |||||
(!(nServices & NODE_NETWORK) && (nServices & NODE_NETWORK_LIMITED)); | |||||
{ | { | ||||
LOCK(pfrom->cs_filter); | LOCK(pfrom->cs_filter); | ||||
// set to true after we get the first filter* message | // set to true after we get the first filter* message | ||||
pfrom->fRelayTxes = fRelay; | pfrom->fRelayTxes = fRelay; | ||||
} | } | ||||
// Change version | // Change version | ||||
pfrom->SetSendVersion(nSendVersion); | pfrom->SetSendVersion(nSendVersion); | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | else if (strCommand == NetMsgType::ADDR) { | ||||
for (CAddress &addr : vAddr) { | for (CAddress &addr : vAddr) { | ||||
if (interruptMsgProc) { | if (interruptMsgProc) { | ||||
return true; | return true; | ||||
} | } | ||||
// We only bother storing full nodes, though this may include things | // We only bother storing full nodes, though this may include things | ||||
// which we would not make an outbound connection to, in part | // which we would not make an outbound connection to, in part | ||||
// because we may make feeler connections to them. | // because we may make feeler connections to them. | ||||
if (!MayHaveUsefulAddressDB(addr.nServices)) { | if (!MayHaveUsefulAddressDB(addr.nServices) && | ||||
!HasAllDesirableServiceFlags(addr.nServices)) { | |||||
continue; | continue; | ||||
} | } | ||||
if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) { | if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) { | ||||
addr.nTime = nNow - 5 * 24 * 60 * 60; | addr.nTime = nNow - 5 * 24 * 60 * 60; | ||||
} | } | ||||
pfrom->AddAddressKnown(addr); | pfrom->AddAddressKnown(addr); | ||||
bool fReachable = IsReachable(addr); | bool fReachable = IsReachable(addr); | ||||
▲ Show 20 Lines • Show All 2,105 Lines • ▼ Show 20 Lines | bool PeerLogicValidation::SendMessages(const Config &config, CNode *pto, | ||||
// Check that outbound peers have reasonable chains GetTime() is used by | // Check that outbound peers have reasonable chains GetTime() is used by | ||||
// this anti-DoS logic so we can test this using mocktime. | // this anti-DoS logic so we can test this using mocktime. | ||||
ConsiderEviction(pto, GetTime()); | ConsiderEviction(pto, GetTime()); | ||||
// | // | ||||
// Message: getdata (blocks) | // Message: getdata (blocks) | ||||
// | // | ||||
std::vector<CInv> vGetData; | std::vector<CInv> vGetData; | ||||
if (!pto->fClient && (fFetch || !IsInitialBlockDownload()) && | if (!pto->fClient && | ||||
((fFetch && !pto->m_limited_node) || !IsInitialBlockDownload()) && | |||||
state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) { | state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) { | ||||
std::vector<const CBlockIndex *> vToDownload; | std::vector<const CBlockIndex *> vToDownload; | ||||
NodeId staller = -1; | NodeId staller = -1; | ||||
FindNextBlocksToDownload(pto->GetId(), | FindNextBlocksToDownload(pto->GetId(), | ||||
MAX_BLOCKS_IN_TRANSIT_PER_PEER - | MAX_BLOCKS_IN_TRANSIT_PER_PEER - | ||||
state.nBlocksInFlight, | state.nBlocksInFlight, | ||||
vToDownload, staller, consensusParams); | vToDownload, staller, consensusParams); | ||||
for (const CBlockIndex *pindex : vToDownload) { | for (const CBlockIndex *pindex : vToDownload) { | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |