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 5,012 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAPOLL) { | ||||
| if (now < | if (now < | ||||
| node_state.last_poll + std::chrono::milliseconds(cooldown)) { | node_state.last_poll + std::chrono::milliseconds(cooldown)) { | ||||
| Misbehaving(pfrom, 20, "avapool-cooldown"); | Misbehaving(pfrom, 20, "avapool-cooldown"); | ||||
| } | } | ||||
| node_state.last_poll = now; | node_state.last_poll = now; | ||||
| } | } | ||||
| const bool quorum_established = | |||||
| g_avalanche && g_avalanche->isQuorumEstablished(); | |||||
| uint64_t round; | uint64_t round; | ||||
| Unserialize(vRecv, round); | Unserialize(vRecv, round); | ||||
| unsigned int nCount = ReadCompactSize(vRecv); | unsigned int nCount = ReadCompactSize(vRecv); | ||||
| if (nCount > AVALANCHE_MAX_ELEMENT_POLL) { | if (nCount > AVALANCHE_MAX_ELEMENT_POLL) { | ||||
| Misbehaving( | Misbehaving( | ||||
| pfrom, 20, | pfrom, 20, | ||||
| strprintf("too-many-ava-poll: poll message size = %u", nCount)); | strprintf("too-many-ava-poll: poll message size = %u", nCount)); | ||||
| return; | return; | ||||
| } | } | ||||
| std::vector<avalanche::Vote> votes; | std::vector<avalanche::Vote> votes; | ||||
| votes.reserve(nCount); | votes.reserve(nCount); | ||||
| LogPrint(BCLog::AVALANCHE, "received avalanche poll from peer=%d\n", | LogPrint(BCLog::AVALANCHE, "received avalanche poll from peer=%d\n", | ||||
| pfrom.GetId()); | pfrom.GetId()); | ||||
| for (unsigned int n = 0; n < nCount; n++) { | for (unsigned int n = 0; n < nCount; n++) { | ||||
| CInv inv; | CInv inv; | ||||
| vRecv >> inv; | vRecv >> inv; | ||||
| // Default vote for unknown inv type | // Default vote for unknown inv type | ||||
| uint32_t vote = -1; | uint32_t vote = -1; | ||||
| // We don't vote definitively until we have an established quorum | |||||
| if (!quorum_established) { | |||||
| votes.emplace_back(vote, inv.hash); | |||||
| 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_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 = | ||||
| ▲ Show 20 Lines • Show All 1,892 Lines • Show Last 20 Lines | |||||