diff --git a/src/avalanche/peermanager.h b/src/avalanche/peermanager.h --- a/src/avalanche/peermanager.h +++ b/src/avalanche/peermanager.h @@ -87,13 +87,11 @@ ProofRef proof; // The network stack uses timestamp in seconds, so we oblige. - std::chrono::seconds registration_time; std::chrono::seconds nextPossibleConflictTime; Peer(PeerId peerid_, ProofRef proof_, std::chrono::seconds nextPossibleConflictTime_) : peerid(peerid_), proof(std::move(proof_)), - registration_time(GetTime()), nextPossibleConflictTime(std::move(nextPossibleConflictTime_)) {} const ProofId &getProofId() const { return proof->getId(); } @@ -380,6 +378,9 @@ return shareableProofs; } + std::optional + getProofRegistrationTime(const ProofId &proofid) const; + private: template void moveToConflictingPool(const ProofContainer &proofs); diff --git a/src/avalanche/peermanager.cpp b/src/avalanche/peermanager.cpp --- a/src/avalanche/peermanager.cpp +++ b/src/avalanche/peermanager.cpp @@ -500,6 +500,18 @@ return conflictingProofPool.getProof(proofid) != nullptr; } +std::optional +PeerManager::getProofRegistrationTime(const ProofId &proofid) const { + for (auto &pool : {validProofPool, conflictingProofPool, orphanProofPool}) { + auto registrationTime = pool.getRegistrationTime(proofid); + if (registrationTime) { + return registrationTime; + } + } + + return {}; +} + bool PeerManager::removePeer(const PeerId peerid) { auto it = peers.find(peerid); if (it == peers.end()) { diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2626,8 +2626,9 @@ // If we know that proof for long enough, allow for requesting // it. - return peer.registration_time <= - now - UNCONDITIONAL_RELAY_DELAY; + auto registrationTime = pm.getProofRegistrationTime(proofid); + return registrationTime && registrationTime.value() <= + now - UNCONDITIONAL_RELAY_DELAY; }); });