Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche.h
Show First 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | private: | ||||
typedef std::chrono::time_point<std::chrono::steady_clock> TimePoint; | typedef std::chrono::time_point<std::chrono::steady_clock> TimePoint; | ||||
struct Peer { | struct Peer { | ||||
NodeId nodeid; | NodeId nodeid; | ||||
int64_t score; | int64_t score; | ||||
TimePoint nextRequestTime; | TimePoint nextRequestTime; | ||||
CPubKey pubkey; | |||||
}; | }; | ||||
typedef boost::multi_index_container< | typedef boost::multi_index_container< | ||||
Peer, boost::multi_index::indexed_by< | Peer, boost::multi_index::indexed_by< | ||||
// index by nodeid | // index by nodeid | ||||
boost::multi_index::hashed_unique< | boost::multi_index::hashed_unique< | ||||
boost::multi_index::member<Peer, NodeId, &Peer::nodeid>>, | boost::multi_index::member<Peer, NodeId, &Peer::nodeid>>, | ||||
// sorted by nextRequestTime | // sorted by nextRequestTime | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | public: | ||||
bool isAccepted(const CBlockIndex *pindex) const; | bool isAccepted(const CBlockIndex *pindex) const; | ||||
int getConfidence(const CBlockIndex *pindex) const; | int getConfidence(const CBlockIndex *pindex) const; | ||||
void sendResponse(CNode *pfrom, AvalancheResponse response) const; | void sendResponse(CNode *pfrom, AvalancheResponse response) const; | ||||
bool registerVotes(NodeId nodeid, const AvalancheResponse &response, | bool registerVotes(NodeId nodeid, const AvalancheResponse &response, | ||||
std::vector<AvalancheBlockUpdate> &updates); | std::vector<AvalancheBlockUpdate> &updates); | ||||
bool addPeer(NodeId nodeid, int64_t score); | bool addPeer(NodeId nodeid, int64_t score, CPubKey pubkey); | ||||
CPubKey getPubKey(NodeId nodeid) const; | |||||
CPubKey getSessionPubKey() const { return sessionKey.GetPubKey(); } | CPubKey getSessionPubKey() const { return sessionKey.GetPubKey(); } | ||||
bool startEventLoop(CScheduler &scheduler); | bool startEventLoop(CScheduler &scheduler); | ||||
bool stopEventLoop(); | bool stopEventLoop(); | ||||
private: | private: | ||||
void runEventLoop(); | void runEventLoop(); | ||||
Show All 13 Lines |