Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 850 Lines • ▼ Show 20 Lines | private: | ||||
void ProcessGetCFHeaders(CNode &peer, CDataStream &vRecv, | void ProcessGetCFHeaders(CNode &peer, CDataStream &vRecv, | ||||
const CChainParams &chain_params, | const CChainParams &chain_params, | ||||
CConnman &connman); | CConnman &connman); | ||||
void ProcessGetCFCheckPt(CNode &peer, CDataStream &vRecv, | void ProcessGetCFCheckPt(CNode &peer, CDataStream &vRecv, | ||||
const CChainParams &chain_params, | const CChainParams &chain_params, | ||||
CConnman &connman); | CConnman &connman); | ||||
/** | /** | ||||
* Decide a response for an Avalanche poll about the given block. | |||||
* | |||||
* @param[in] hash The hash of the block being polled for | |||||
* @param[out] uint32_t Our current vote for the block | |||||
*/ | |||||
uint32_t GetAvalancheVoteForBlock(const BlockHash &hash) | |||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
/** | |||||
* Checks if address relay is permitted with peer. If needed, initializes | * Checks if address relay is permitted with peer. If needed, initializes | ||||
* the m_addr_known bloom filter and sets m_addr_relay_enabled to true. | * the m_addr_known bloom filter and sets m_addr_relay_enabled to true. | ||||
* | * | ||||
* @return True if address relay is enabled with peer | * @return True if address relay is enabled with peer | ||||
* False if address relay is disallowed | * False if address relay is disallowed | ||||
*/ | */ | ||||
bool SetupAddressRelay(CNode &node, Peer &peer); | bool SetupAddressRelay(CNode &node, Peer &peer); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 2,360 Lines • ▼ Show 20 Lines | |||||
bool IsAvalancheMessageType(const std::string &msg_type) { | bool IsAvalancheMessageType(const std::string &msg_type) { | ||||
return msg_type == NetMsgType::AVAHELLO || | return msg_type == NetMsgType::AVAHELLO || | ||||
msg_type == NetMsgType::AVAPOLL || | msg_type == NetMsgType::AVAPOLL || | ||||
msg_type == NetMsgType::AVARESPONSE || | msg_type == NetMsgType::AVARESPONSE || | ||||
msg_type == NetMsgType::AVAPROOF || | msg_type == NetMsgType::AVAPROOF || | ||||
msg_type == NetMsgType::GETAVAADDR; | msg_type == NetMsgType::GETAVAADDR; | ||||
} | } | ||||
/** | uint32_t PeerManagerImpl::GetAvalancheVoteForBlock(const BlockHash &hash) { | ||||
* Decide a response for an Avalanche poll about the given block. | |||||
* | |||||
* @param[in] hash The hash of the block being polled for | |||||
* @param[out] uint32_t Our current vote for the block | |||||
*/ | |||||
static uint32_t getAvalancheVoteForBlock(const BlockHash &hash) | |||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | |||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
const CBlockIndex *pindex = g_chainman.m_blockman.LookupBlockIndex(hash); | const CBlockIndex *pindex = g_chainman.m_blockman.LookupBlockIndex(hash); | ||||
// Unknown block. | // Unknown block. | ||||
if (!pindex) { | if (!pindex) { | ||||
return -1; | return -1; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,674 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAPOLL) { | ||||
} | } | ||||
// If inv's type is known, get a vote for its hash | // If inv's type is known, get a vote for its hash | ||||
switch (inv.type) { | switch (inv.type) { | ||||
case MSG_TX: { | case MSG_TX: { | ||||
vote = getAvalancheVoteForTx(m_mempool, TxId(inv.hash)); | vote = getAvalancheVoteForTx(m_mempool, TxId(inv.hash)); | ||||
} break; | } break; | ||||
case MSG_BLOCK: { | case MSG_BLOCK: { | ||||
vote = WITH_LOCK(cs_main, return getAvalancheVoteForBlock( | vote = WITH_LOCK(cs_main, return GetAvalancheVoteForBlock( | ||||
BlockHash(inv.hash))); | BlockHash(inv.hash))); | ||||
} break; | } break; | ||||
case MSG_AVA_PROOF: { | case MSG_AVA_PROOF: { | ||||
vote = | vote = | ||||
getAvalancheVoteForProof(avalanche::ProofId(inv.hash)); | getAvalancheVoteForProof(avalanche::ProofId(inv.hash)); | ||||
} break; | } break; | ||||
default: { | default: { | ||||
LogPrint(BCLog::AVALANCHE, | LogPrint(BCLog::AVALANCHE, | ||||
▲ Show 20 Lines • Show All 1,896 Lines • Show Last 20 Lines |