Changeset View
Changeset View
Standalone View
Standalone View
src/txrequest.h
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | |||||
* Complexity: | * Complexity: | ||||
* - Memory usage is proportional to the total number of tracked announcements | * - Memory usage is proportional to the total number of tracked announcements | ||||
* (Size()) plus the number of peers with a nonzero number of tracked | * (Size()) plus the number of peers with a nonzero number of tracked | ||||
* announcements. | * announcements. | ||||
* - CPU usage is generally logarithmic in the total number of tracked | * - CPU usage is generally logarithmic in the total number of tracked | ||||
* announcements, plus the number of announcements affected by an operation | * announcements, plus the number of announcements affected by an operation | ||||
* (amortized O(1) per announcement). | * (amortized O(1) per announcement). | ||||
*/ | */ | ||||
class TxRequestTracker { | |||||
// Avoid littering this header file with implementation details. | // Avoid littering this header file with implementation details. | ||||
class Impl; | class Impl { | ||||
deadalnix: It doesn't sound like a name that stands on its own. Impl was previous scoped, so it somewhat… | |||||
friend class TxRequestTracker; | |||||
// The base class is responsible for building the child implementation. | |||||
// This is a hack that allows for hiding the concrete implementation details | |||||
// from the callsite. | |||||
static std::unique_ptr<Impl> BuildImpl(bool deterministic); | |||||
protected: | |||||
deadalnixUnsubmitted Not Done Inline ActionsThis most likely should be public. deadalnix: This most likely should be public. | |||||
using clearExpiredFun = const std::function<void()> &; | |||||
using emplaceExpiredFun = | |||||
deadalnixUnsubmitted Not Done Inline ActionsCapitalize types. deadalnix: Capitalize types. | |||||
const std::function<void(const NodeId &, const uint256 &)> &; | |||||
virtual void ReceivedInv(NodeId peer, const uint256 &txid, bool preferred, | |||||
std::chrono::microseconds reqtime) = 0; | |||||
virtual void DisconnectedPeer(NodeId peer) = 0; | |||||
virtual void ForgetTxId(const uint256 &txid) = 0; | |||||
virtual std::vector<uint256> | |||||
deadalnixUnsubmitted Not Done Inline ActionsNote that you almost certainly creates copies when you call these. deadalnix: Note that you almost certainly creates copies when you call these. | |||||
GetRequestable(NodeId peer, std::chrono::microseconds now, | |||||
clearExpiredFun clearExpired, | |||||
emplaceExpiredFun emplaceExpired) = 0; | |||||
virtual void RequestedTx(NodeId peer, const uint256 &txid, | |||||
std::chrono::microseconds expiry) = 0; | |||||
virtual void ReceivedResponse(NodeId peer, const uint256 &txid) = 0; | |||||
virtual size_t CountInFlight(NodeId peer) const = 0; | |||||
virtual size_t CountCandidates(NodeId peer) const = 0; | |||||
virtual size_t Count(NodeId peer) const = 0; | |||||
virtual size_t Size() const = 0; | |||||
virtual uint64_t ComputePriority(const uint256 &txid, NodeId peer, | |||||
bool preferred) const = 0; | |||||
virtual void SanityCheck() const = 0; | |||||
virtual void | |||||
PostGetRequestableSanityCheck(std::chrono::microseconds now) const = 0; | |||||
public: | |||||
virtual ~Impl() = default; | |||||
}; | |||||
class TxRequestTracker { | |||||
const std::unique_ptr<Impl> m_impl; | const std::unique_ptr<Impl> m_impl; | ||||
public: | public: | ||||
//! Construct a TxRequestTracker. | //! Construct a TxRequestTracker. | ||||
explicit TxRequestTracker(bool deterministic = false); | explicit TxRequestTracker(bool deterministic = false); | ||||
~TxRequestTracker(); | ~TxRequestTracker(); | ||||
// Conceptually, the data structure consists of a collection of | // Conceptually, the data structure consists of a collection of | ||||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |
It doesn't sound like a name that stands on its own. Impl was previous scoped, so it somewhat made sense, but it doesn't now.