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 3,427 Lines • ▼ Show 20 Lines | static uint32_t getAvalancheVoteForBlock(const BlockHash &hash) | ||||
| } | } | ||||
| // This block is built on top of the tip, we have the data, it | // This block is built on top of the tip, we have the data, it | ||||
| // is pending connection or rejection. | // is pending connection or rejection. | ||||
| return -3; | return -3; | ||||
| }; | }; | ||||
| /** | /** | ||||
| * Decide a response for an Avalanche poll about the given transaction. | |||||
| * | |||||
| * FIXME This function should be expanded to return different vote responses | |||||
| * based on inspection of mempool. | |||||
| * | |||||
| * @param[in] CTxMemPool The mempool to base our votes on | |||||
| * @param[in] TxId The id of the transaction being polled for | |||||
| * @param[out] uint32_t Our current vote for the proof | |||||
| */ | |||||
| static uint32_t getAvalancheVoteForTx(CTxMemPool &mempool, const TxId &id) { | |||||
| return -1; | |||||
| }; | |||||
| /** | |||||
| * Decide a response for an Avalanche poll about the given proof. | * Decide a response for an Avalanche poll about the given proof. | ||||
| * | * | ||||
| * @param[in] avalanche::ProofId The id of the proof being polled for | * @param[in] avalanche::ProofId The id of the proof being polled for | ||||
| * @param[out] uint32_t Our current vote for the proof | * @param[out] uint32_t Our current vote for the proof | ||||
| */ | */ | ||||
| static uint32_t getAvalancheVoteForProof(const avalanche::ProofId &id) { | static uint32_t getAvalancheVoteForProof(const avalanche::ProofId &id) { | ||||
| assert(g_avalanche); | assert(g_avalanche); | ||||
| ▲ Show 20 Lines • Show All 1,615 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAPOLL) { | ||||
| // We don't vote definitively until we have an established quorum | // We don't vote definitively until we have an established quorum | ||||
| if (!quorum_established) { | if (!quorum_established) { | ||||
| votes.emplace_back(vote, inv.hash); | votes.emplace_back(vote, inv.hash); | ||||
| continue; | continue; | ||||
| } | } | ||||
| // 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: { | |||||
| vote = getAvalancheVoteForTx(m_mempool, TxId(inv.hash)); | |||||
| } 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; | ||||
| ▲ Show 20 Lines • Show All 1,891 Lines • Show Last 20 Lines | |||||