Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
| Show First 20 Lines • Show All 1,183 Lines • ▼ Show 20 Lines | AnyVoteItem Processor::getVoteItemFromInv(const CInv &inv) const { | ||||
| } | } | ||||
| if (inv.IsMsgProof()) { | if (inv.IsMsgProof()) { | ||||
| return WITH_LOCK(cs_peerManager, | return WITH_LOCK(cs_peerManager, | ||||
| return peerManager->getProof(ProofId(inv.hash))); | return peerManager->getProof(ProofId(inv.hash))); | ||||
| } | } | ||||
| if (mempool && inv.IsMsgTx()) { | if (mempool && inv.IsMsgTx()) { | ||||
| return WITH_LOCK(mempool->cs, return mempool->get(TxId(inv.hash))); | LOCK(mempool->cs); | ||||
| if (CTransactionRef tx = mempool->get(TxId(inv.hash))) { | |||||
| return tx; | |||||
| } | |||||
| if (CTransactionRef tx = mempool->withConflicting( | |||||
| [&inv](const TxConflicting &conflicting) { | |||||
| return conflicting.GetTx(TxId(inv.hash)); | |||||
| })) { | |||||
| return tx; | |||||
| } | |||||
| } | } | ||||
| return {nullptr}; | return {nullptr}; | ||||
| } | } | ||||
| bool Processor::IsWorthPolling::operator()(const CBlockIndex *pindex) const { | bool Processor::IsWorthPolling::operator()(const CBlockIndex *pindex) const { | ||||
| AssertLockNotHeld(cs_main); | AssertLockNotHeld(cs_main); | ||||
| Show All 37 Lines | return processor.peerManager->isBoundToPeer(proofid) || | ||||
| processor.peerManager->isInConflictingPool(proofid); | processor.peerManager->isInConflictingPool(proofid); | ||||
| } | } | ||||
| bool Processor::IsWorthPolling::operator()(const CTransactionRef &tx) const { | bool Processor::IsWorthPolling::operator()(const CTransactionRef &tx) const { | ||||
| if (!processor.mempool) { | if (!processor.mempool) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| // TODO For now the transactions with conflicts or rejected by policies are | |||||
| // not stored anywhere, so only the mempool transactions are worth polling. | |||||
| AssertLockNotHeld(processor.mempool->cs); | AssertLockNotHeld(processor.mempool->cs); | ||||
| return WITH_LOCK(processor.mempool->cs, | LOCK(processor.mempool->cs); | ||||
| return processor.mempool->exists(tx->GetId())); | |||||
| return processor.mempool->exists(tx->GetId()) || | |||||
| processor.mempool->withConflicting( | |||||
| [&tx](const TxConflicting &conflicting) { | |||||
| return conflicting.HaveTx(tx->GetId()); | |||||
| }); | |||||
| } | } | ||||
| bool Processor::isWorthPolling(const AnyVoteItem &item) const { | bool Processor::isWorthPolling(const AnyVoteItem &item) const { | ||||
| return std::visit(IsWorthPolling(*this), item) && | return std::visit(IsWorthPolling(*this), item) && | ||||
| !isRecentlyFinalized(GetVoteItemId(item)); | !isRecentlyFinalized(GetVoteItemId(item)); | ||||
| } | } | ||||
| bool Processor::GetLocalAcceptance::operator()( | bool Processor::GetLocalAcceptance::operator()( | ||||
| Show All 28 Lines | |||||