Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultLatencyResolution = 100
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilterFunc ¶
FilterFunc is a function which determines whether a request should be enqueued or not.
type Queue ¶
type Queue interface { // Next returns the next request to send, pops it from the queue and marks it as pending. Next() *Request // Peek returns the next request to send without popping it from the queue. Peek() *Request // Enqueue enqueues the given request if it isn't already queued or pending. Enqueue(*Request) (enqueued bool) // IsQueued tells whether a given request for the given transaction hash is queued. IsQueued(hash hornet.Hash) bool // IsPending tells whether a given request was popped from the queue and is now pending. IsPending(hash hornet.Hash) bool // IsProcessing tells whether a given request was popped from the queue, received and is now processing. IsProcessing(hash hornet.Hash) bool // Received marks a request as received and thereby removes it from the pending set. // It is added to the processing set. // Returns the origin request which was pending or nil if the hash was not requested. Received(hash hornet.Hash) *Request // Processed marks a request as fulfilled and thereby removes it from the processing set. // Returns the origin request which was pending or nil if the hash was not requested. Processed(hash hornet.Hash) *Request // EnqueuePending enqueues all pending requests back into the queue. // It also discards requests in the pending set of which their enqueue time is over the given delta threshold. // If discardOlderThan is zero, no requests are discarded. EnqueuePending(discardOlderThan time.Duration) (queued int) // Size returns the size of currently queued, requested/pending and processing requests. Size() (queued int, pending int, processing int) // Empty tells whether the queue has no queued and pending requests. Empty() bool // Requests returns a snapshot of all queued, pending and processing requests in the queue. Requests() (queued []*Request, pending []*Request, processing []*Request) // AvgLatency returns the average latency of enqueueing and then receiving a request. AvgLatency() int64 // Filter adds the given filter function to the queue. Passing nil resets the current one. // Setting a filter automatically clears all queued and pending requests which do not fulfill // the filter criteria. Filter(f FilterFunc) }
Queue implements a queue which contains requests for needed data.
type Request ¶
type Request struct { // The hash of the transaction to request. Hash hornet.Hash // The milestone index under which this request is linked. MilestoneIndex milestone.Index // Tells the request queue to not remove this request if the enqueue time is // over the given threshold. PreventDiscard bool // the time at which this request was first enqueued. // do not modify this time EnqueueTime time.Time // contains filtered or unexported fields }
Request is a request for a particular transaction.
Click to show internal directories.
Click to hide internal directories.