Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.cpp
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | bool PeerManager::updateNextRequestTime(NodeId nodeid, TimePoint timeout) { | ||||
return nodes.modify(it, [&](Node &n) { n.nextRequestTime = timeout; }); | return nodes.modify(it, [&](Node &n) { n.nextRequestTime = timeout; }); | ||||
} | } | ||||
static bool isOrphanState(const ProofValidationState &state) { | static bool isOrphanState(const ProofValidationState &state) { | ||||
return state.GetResult() == ProofValidationResult::MISSING_UTXO || | return state.GetResult() == ProofValidationResult::MISSING_UTXO || | ||||
state.GetResult() == ProofValidationResult::HEIGHT_MISMATCH; | state.GetResult() == ProofValidationResult::HEIGHT_MISMATCH; | ||||
} | } | ||||
bool PeerManager::updateNextPossibleConflictTime( | |||||
PeerId peerid, const std::chrono::seconds &nextTime) { | |||||
auto it = peers.find(peerid); | |||||
if (it == peers.end()) { | |||||
// No such peer | |||||
return false; | |||||
} | |||||
// Make sure we don't move the time in the past. | |||||
peers.modify(it, [&](Peer &p) { | |||||
p.nextPossibleConflictTime = | |||||
std::max(p.nextPossibleConflictTime, nextTime); | |||||
}); | |||||
return it->nextPossibleConflictTime == nextTime; | |||||
} | |||||
bool PeerManager::registerProof(const ProofRef &proof) { | bool PeerManager::registerProof(const ProofRef &proof) { | ||||
assert(proof); | assert(proof); | ||||
const ProofId &proofid = proof->getId(); | const ProofId &proofid = proof->getId(); | ||||
if (exists(proofid)) { | if (exists(proofid)) { | ||||
// The proof is already registered, or orphaned. | // The proof is already registered, or orphaned. | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 411 Lines • Show Last 20 Lines |