Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.h
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | public: | ||||
const VoteStatus &getStatus() const { return status; } | const VoteStatus &getStatus() const { return status; } | ||||
VoteItem getVoteItem() { return item; } | VoteItem getVoteItem() { return item; } | ||||
const VoteItem getVoteItem() const { return item; } | const VoteItem getVoteItem() const { return item; } | ||||
}; | }; | ||||
using BlockUpdate = VoteItemUpdate<CBlockIndex *>; | using BlockUpdate = VoteItemUpdate<CBlockIndex *>; | ||||
using ProofUpdate = VoteItemUpdate<std::shared_ptr<Proof>>; | 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 std::shared_ptr<Proof>, VoteRecord, | using ProofVoteMap = std::map<const ProofRef, VoteRecord, ProofRefComparator>; | ||||
ProofSharedPointerComparator>; | |||||
struct query_timeout {}; | struct query_timeout {}; | ||||
namespace { | namespace { | ||||
struct AvalancheTest; | struct AvalancheTest; | ||||
} | } | ||||
class Processor { | class Processor { | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | static std::unique_ptr<Processor> MakeProcessor(const ArgsManager &argsman, | ||||
CConnman *connman, | CConnman *connman, | ||||
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 std::shared_ptr<Proof> &proof, | void addProofToReconcile(const ProofRef &proof, bool isAccepted); | ||||
bool isAccepted); | |||||
bool isAccepted(const CBlockIndex *pindex) const; | bool isAccepted(const CBlockIndex *pindex) const; | ||||
bool isAccepted(const std::shared_ptr<Proof> &proof) const; | bool isAccepted(const ProofRef &proof) const; | ||||
int getConfidence(const CBlockIndex *pindex) const; | int getConfidence(const CBlockIndex *pindex) const; | ||||
int getConfidence(const std::shared_ptr<Proof> &proof) const; | int getConfidence(const ProofRef &proof) 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); | ||||
template <typename Callable> auto withPeerManager(Callable &&func) const { | template <typename Callable> auto withPeerManager(Callable &&func) const { | ||||
LOCK(cs_peerManager); | LOCK(cs_peerManager); | ||||
return func(*peerManager); | return func(*peerManager); | ||||
} | } | ||||
CPubKey getSessionPubKey() const; | CPubKey getSessionPubKey() const; | ||||
bool sendHello(CNode *pfrom) const; | bool sendHello(CNode *pfrom) const; | ||||
std::shared_ptr<Proof> getLocalProof() const; | ProofRef getLocalProof() const; | ||||
/* | /* | ||||
* Return whether the avalanche service flag should be set. | * Return whether the avalanche service flag should be set. | ||||
*/ | */ | ||||
bool isAvalancheServiceAvailable() { return !!peerData; } | bool isAvalancheServiceAvailable() { return !!peerData; } | ||||
bool startEventLoop(CScheduler &scheduler); | bool startEventLoop(CScheduler &scheduler); | ||||
bool stopEventLoop(); | bool stopEventLoop(); | ||||
Show All 19 Lines |