Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
| Show First 20 Lines • Show All 647 Lines • ▼ Show 20 Lines | // First remove all blocks that are not worth polling. | ||||
| } | } | ||||
| } | } | ||||
| auto r = blockVoteRecords.getReadView(); | auto r = blockVoteRecords.getReadView(); | ||||
| extractVoteRecordsToInvs(reverse_iterate(r), [](const CBlockIndex *pindex) { | extractVoteRecordsToInvs(reverse_iterate(r), [](const CBlockIndex *pindex) { | ||||
| return CInv(MSG_BLOCK, pindex->GetBlockHash()); | return CInv(MSG_BLOCK, pindex->GetBlockHash()); | ||||
| }); | }); | ||||
| // Now fill up with transactions. | |||||
| extractVoteRecordsToInvs( | |||||
Fabien: Need to bail out if the inv vector is full | |||||
| txVoteRecords.getReadView(), | |||||
| [](const CTransactionRef &tx) { return CInv(MSG_TX, tx->GetId()); }); | |||||
| return invs; | return invs; | ||||
| } | } | ||||
| NodeId Processor::getSuitableNodeToQuery() { | NodeId Processor::getSuitableNodeToQuery() { | ||||
| LOCK(cs_peerManager); | LOCK(cs_peerManager); | ||||
| return peerManager->selectNode(); | return peerManager->selectNode(); | ||||
| } | } | ||||
| Show All 33 Lines | auto clearInflightRequest = [&](auto &voteRecords, const auto &voteItem, | ||||
| it->second.clearInflightRequest(count); | it->second.clearInflightRequest(count); | ||||
| return true; | return true; | ||||
| }; | }; | ||||
| // In flight request accounting. | // In flight request accounting. | ||||
| for (const auto &p : timedout_items) { | for (const auto &p : timedout_items) { | ||||
| const CInv &inv = p.first; | const CInv &inv = p.first; | ||||
| if (inv.IsMsgTx()) { | |||||
FabienUnsubmitted Not Done Inline ActionsKeep ordering consistent, and factorize the logic Fabien: Keep ordering consistent, and factorize the logic | |||||
| CTransactionRef tx = mempool.get(TxId(inv.hash)); | |||||
| if (!clearInflightRequest(txVoteRecords, tx, p.second)) { | |||||
| continue; | |||||
| } | |||||
| } | |||||
| if (inv.IsMsgBlk()) { | if (inv.IsMsgBlk()) { | ||||
| const CBlockIndex *pindex = WITH_LOCK( | const CBlockIndex *pindex = WITH_LOCK( | ||||
| cs_main, return g_chainman.m_blockman.LookupBlockIndex( | cs_main, return g_chainman.m_blockman.LookupBlockIndex( | ||||
| BlockHash(inv.hash))); | BlockHash(inv.hash))); | ||||
| if (!clearInflightRequest(blockVoteRecords, pindex, p.second)) { | if (!clearInflightRequest(blockVoteRecords, pindex, p.second)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines | |||||
Need to bail out if the inv vector is full