Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show First 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | bool registerProof(const ProofRef &proof, | ||||
ProofRegistrationState ®istrationState, | ProofRegistrationState ®istrationState, | ||||
RegistrationMode mode = RegistrationMode::DEFAULT); | RegistrationMode mode = RegistrationMode::DEFAULT); | ||||
bool registerProof(const ProofRef &proof, | bool registerProof(const ProofRef &proof, | ||||
RegistrationMode mode = RegistrationMode::DEFAULT) { | RegistrationMode mode = RegistrationMode::DEFAULT) { | ||||
ProofRegistrationState dummy; | ProofRegistrationState dummy; | ||||
return registerProof(proof, dummy, mode); | return registerProof(proof, dummy, mode); | ||||
} | } | ||||
/** | |||||
* Rejection mode | |||||
* - DEFAULT: Default policy, reject a proof and attempt to keep it in the | |||||
* conflicting pool if possible. | |||||
* - INVALIDATE: Reject a proof by removing it from any of the pool. | |||||
* | |||||
* In any case if a peer is rejected, it attempts to pull the conflicting | |||||
* proofs back. | |||||
*/ | |||||
enum class RejectionMode { | |||||
DEFAULT, | |||||
INVALIDATE, | |||||
}; | |||||
bool rejectProof(const ProofId &proofid, | |||||
RejectionMode mode = RejectionMode::DEFAULT); | |||||
bool exists(const ProofId &proofid) const { | bool exists(const ProofId &proofid) const { | ||||
return getProof(proofid) != nullptr; | return getProof(proofid) != nullptr; | ||||
} | } | ||||
template <typename Callable> | template <typename Callable> | ||||
bool forPeer(const ProofId &proofid, Callable &&func) const { | bool forPeer(const ProofId &proofid, Callable &&func) const { | ||||
auto &pview = peers.get<by_proofid>(); | auto &pview = peers.get<by_proofid>(); | ||||
auto it = pview.find(proofid); | auto it = pview.find(proofid); | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |