Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 488 Lines • ▼ Show 20 Lines | struct CNodeState { | ||||
//! Whether this peer is a manual connection | //! Whether this peer is a manual connection | ||||
bool m_is_manual_connection; | bool m_is_manual_connection; | ||||
//! A rolling bloom filter of all announced tx CInvs to this peer. | //! A rolling bloom filter of all announced tx CInvs to this peer. | ||||
CRollingBloomFilter m_recently_announced_invs = | CRollingBloomFilter m_recently_announced_invs = | ||||
CRollingBloomFilter{INVENTORY_MAX_RECENT_RELAY, 0.000001}; | CRollingBloomFilter{INVENTORY_MAX_RECENT_RELAY, 0.000001}; | ||||
//! A rolling bloom filter of all announced Proofs CInvs to this peer. | |||||
CRollingBloomFilter m_recently_announced_proofs = | |||||
CRollingBloomFilter{INVENTORY_MAX_RECENT_RELAY, 0.000001}; | |||||
CNodeState(CAddress addrIn, bool is_inbound, bool is_manual) | CNodeState(CAddress addrIn, bool is_inbound, bool is_manual) | ||||
: address(addrIn), m_is_inbound(is_inbound), | : address(addrIn), m_is_inbound(is_inbound), | ||||
m_is_manual_connection(is_manual) { | m_is_manual_connection(is_manual) { | ||||
fCurrentlyConnected = false; | fCurrentlyConnected = false; | ||||
pindexBestKnownBlock = nullptr; | pindexBestKnownBlock = nullptr; | ||||
hashLastUnknownBlock = BlockHash(); | hashLastUnknownBlock = BlockHash(); | ||||
pindexLastCommonBlock = nullptr; | pindexLastCommonBlock = nullptr; | ||||
pindexBestHeaderSent = nullptr; | pindexBestHeaderSent = nullptr; | ||||
nUnconnectingHeaders = 0; | nUnconnectingHeaders = 0; | ||||
fSyncStarted = false; | fSyncStarted = false; | ||||
nHeadersSyncTimeout = 0; | nHeadersSyncTimeout = 0; | ||||
nStallingSince = 0; | nStallingSince = 0; | ||||
nDownloadingSince = 0; | nDownloadingSince = 0; | ||||
nBlocksInFlight = 0; | nBlocksInFlight = 0; | ||||
nBlocksInFlightValidHeaders = 0; | nBlocksInFlightValidHeaders = 0; | ||||
fPreferredDownload = false; | fPreferredDownload = false; | ||||
fPreferHeaders = false; | fPreferHeaders = false; | ||||
fPreferHeaderAndIDs = false; | fPreferHeaderAndIDs = false; | ||||
fProvidesHeaderAndIDs = false; | fProvidesHeaderAndIDs = false; | ||||
fSupportsDesiredCmpctVersion = false; | fSupportsDesiredCmpctVersion = false; | ||||
m_chain_sync = {0, nullptr, false, false}; | m_chain_sync = {0, nullptr, false, false}; | ||||
m_last_block_announcement = 0; | m_last_block_announcement = 0; | ||||
m_recently_announced_invs.reset(); | m_recently_announced_invs.reset(); | ||||
m_recently_announced_proofs.reset(); | |||||
} | } | ||||
}; | }; | ||||
/** Map maintaining per-node state. */ | /** Map maintaining per-node state. */ | ||||
static std::map<NodeId, CNodeState> mapNodeState GUARDED_BY(cs_main); | static std::map<NodeId, CNodeState> mapNodeState GUARDED_BY(cs_main); | ||||
static CNodeState *State(NodeId pnode) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | static CNodeState *State(NodeId pnode) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||||
std::map<NodeId, CNodeState>::iterator it = mapNodeState.find(pnode); | std::map<NodeId, CNodeState>::iterator it = mapNodeState.find(pnode); | ||||
▲ Show 20 Lines • Show All 2,412 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::VERACK) { | ||||
nCMPCTBLOCKVersion)); | nCMPCTBLOCKVersion)); | ||||
} | } | ||||
if ((pfrom.nServices & NODE_AVALANCHE) && g_avalanche && | if ((pfrom.nServices & NODE_AVALANCHE) && g_avalanche && | ||||
gArgs.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | gArgs.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | ||||
if (g_avalanche->sendHello(&pfrom)) { | if (g_avalanche->sendHello(&pfrom)) { | ||||
LogPrint(BCLog::NET, "Send avahello to peer %d\n", | LogPrint(BCLog::NET, "Send avahello to peer %d\n", | ||||
pfrom.GetId()); | pfrom.GetId()); | ||||
auto localProof = g_avalanche->getLocalProof(); | |||||
// If we sent a hello message, we should have a proof | |||||
assert(localProof); | |||||
// Add our proof id to the list or the recently announced proof | |||||
// INVs to this peer. This is used for filtering which INV can | |||||
// be requested for download. | |||||
LOCK(cs_main); | |||||
State(pfrom.GetId()) | |||||
->m_recently_announced_proofs.insert(localProof->getId()); | |||||
} | } | ||||
} | } | ||||
pfrom.fSuccessfullyConnected = true; | pfrom.fSuccessfullyConnected = true; | ||||
return; | return; | ||||
} | } | ||||
if (!pfrom.fSuccessfullyConnected) { | if (!pfrom.fSuccessfullyConnected) { | ||||
▲ Show 20 Lines • Show All 2,712 Lines • Show Last 20 Lines |