Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.h
| Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
| }; | }; | ||||
| using BlockUpdate = VoteItemUpdate<CBlockIndex *>; | using BlockUpdate = VoteItemUpdate<CBlockIndex *>; | ||||
| using ProofUpdate = VoteItemUpdate<ProofRef>; | using ProofUpdate = VoteItemUpdate<ProofRef>; | ||||
| using BlockVoteMap = | using BlockVoteMap = | ||||
| std::map<const CBlockIndex *, VoteRecord, CBlockIndexWorkComparator>; | std::map<const CBlockIndex *, VoteRecord, CBlockIndexWorkComparator>; | ||||
| using ProofVoteMap = std::map<const ProofRef, VoteRecord, ProofComparator>; | using ProofVoteMap = std::map<const ProofRef, VoteRecord, ProofComparator>; | ||||
| using TxVoteMap = std::map<const CTransactionRef, VoteRecord>; | |||||
| struct query_timeout {}; | struct query_timeout {}; | ||||
| namespace { | namespace { | ||||
| struct AvalancheTest; | struct AvalancheTest; | ||||
| } | } | ||||
| // FIXME Implement a proper notification handler for node disconnection instead | // FIXME Implement a proper notification handler for node disconnection instead | ||||
| // of implementing the whole NetEventsInterface for a single interesting event. | // of implementing the whole NetEventsInterface for a single interesting event. | ||||
| class Processor final : public NetEventsInterface { | class Processor final : public NetEventsInterface { | ||||
| CConnman *connman; | CConnman *connman; | ||||
| std::chrono::milliseconds queryTimeoutDuration; | std::chrono::milliseconds queryTimeoutDuration; | ||||
| /** | /** | ||||
| * Blocks to run avalanche on. | * Blocks to run avalanche on. | ||||
| */ | */ | ||||
| RWCollection<BlockVoteMap> blockVoteRecords; | RWCollection<BlockVoteMap> blockVoteRecords; | ||||
| /** | /** | ||||
| * Proofs to run avalanche on. | * Proofs to run avalanche on. | ||||
| */ | */ | ||||
| RWCollection<ProofVoteMap> proofVoteRecords; | RWCollection<ProofVoteMap> proofVoteRecords; | ||||
| /** | /** | ||||
| * Transactions to run avalanche on. | |||||
| */ | |||||
| RWCollection<TxVoteMap> txVoteRecords; | |||||
| /** | |||||
| * Keep track of peers and queries sent. | * Keep track of peers and queries sent. | ||||
| */ | */ | ||||
| std::atomic<uint64_t> round; | std::atomic<uint64_t> round; | ||||
| /** | /** | ||||
| * Keep track of the peers and associated infos. | * Keep track of the peers and associated infos. | ||||
| */ | */ | ||||
| mutable Mutex cs_peerManager; | mutable Mutex cs_peerManager; | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | static std::unique_ptr<Processor> MakeProcessor(const ArgsManager &argsman, | ||||
| bilingual_str &error); | bilingual_str &error); | ||||
| void setQueryTimeoutDuration(std::chrono::milliseconds d) { | void setQueryTimeoutDuration(std::chrono::milliseconds d) { | ||||
| queryTimeoutDuration = d; | queryTimeoutDuration = d; | ||||
| } | } | ||||
| bool addBlockToReconcile(const CBlockIndex *pindex); | bool addBlockToReconcile(const CBlockIndex *pindex); | ||||
| void addProofToReconcile(const ProofRef &proof); | void addProofToReconcile(const ProofRef &proof); | ||||
| bool addTxToReconcile(const CTransactionRef &tx); | |||||
| bool isAccepted(const CBlockIndex *pindex) const; | bool isAccepted(const CBlockIndex *pindex) const; | ||||
| bool isAccepted(const ProofRef &proof) const; | bool isAccepted(const ProofRef &proof) const; | ||||
| bool isAccepted(const CTransactionRef &tx) const; | |||||
| int getConfidence(const CBlockIndex *pindex) const; | int getConfidence(const CBlockIndex *pindex) const; | ||||
| int getConfidence(const ProofRef &proof) const; | int getConfidence(const ProofRef &proof) const; | ||||
| int getConfidence(const CTransactionRef &tx) const; | |||||
| // TODO: Refactor the API to remove the dependency on avalanche/protocol.h | // TODO: Refactor the API to remove the dependency on avalanche/protocol.h | ||||
| void sendResponse(CNode *pfrom, Response response) const; | void sendResponse(CNode *pfrom, Response response) const; | ||||
| bool registerVotes(NodeId nodeid, const Response &response, | bool registerVotes(NodeId nodeid, const Response &response, | ||||
| std::vector<BlockUpdate> &blockUpdates, | std::vector<BlockUpdate> &blockUpdates, | ||||
| std::vector<ProofUpdate> &proofUpdates, int &banscore, | std::vector<ProofUpdate> &proofUpdates, int &banscore, | ||||
| std::string &error); | std::string &error); | ||||
| ▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines | |||||