Documentation ¶
Index ¶
- Constants
- Variables
- type BufferQueue
- func (b *BufferQueue) Current() *NodeQueue
- func (b *BufferQueue) IDs() (ids []ElementID)
- func (b *BufferQueue) Next() *NodeQueue
- func (b *BufferQueue) NodeIDs() []identity.ID
- func (b *BufferQueue) NodeQueue(nodeID identity.ID) *NodeQueue
- func (b *BufferQueue) NumActiveNodes() int
- func (b *BufferQueue) PopFront() Element
- func (b *BufferQueue) Ready(msg Element) bool
- func (b *BufferQueue) RemoveNode(nodeID identity.ID)
- func (b *BufferQueue) Size() int
- func (b *BufferQueue) Submit(msg Element, rep float64) error
- func (b *BufferQueue) Unsubmit(msg Element) bool
- type Element
- type ElementHeap
- type ElementID
- type NodeQueue
- func (q *NodeQueue) Front() Element
- func (q *NodeQueue) IDs() (ids []ElementID)
- func (q *NodeQueue) NodeID() identity.ID
- func (q *NodeQueue) PopFront() Element
- func (q *NodeQueue) Ready(element Element) bool
- func (q *NodeQueue) Size() int
- func (q *NodeQueue) Submit(element Element) bool
- func (q *NodeQueue) Unsubmit(element Element) bool
Constants ¶
const ElementIDLength = 32
ElementIDLength defines the length of an ElementID.
Variables ¶
var ( // ErrInboxExceeded is returned when a node has exceeded its allowed inbox size. ErrInboxExceeded = errors.New("maximum mana-scaled inbox length exceeded") // ErrInsufficientMana is returned when the mana is insufficient. ErrInsufficientMana = errors.New("insufficient node's mana to schedule the message") // ErrBufferFull is returned when the maximum buffer size is exceeded. ErrBufferFull = errors.New("maximum buffer size exceeded") )
Functions ¶
This section is empty.
Types ¶
type BufferQueue ¶
type BufferQueue struct {
// contains filtered or unexported fields
}
BufferQueue represents a buffer of NodeQueue
func NewBufferQueue ¶
func NewBufferQueue(maxBuffer int, maxQueue float64) *BufferQueue
NewBufferQueue returns a new BufferQueue.
func (*BufferQueue) Current ¶
func (b *BufferQueue) Current() *NodeQueue
Current returns the current NodeQueue in round robin order.
func (*BufferQueue) IDs ¶
func (b *BufferQueue) IDs() (ids []ElementID)
IDs returns the IDs of all submitted messages (ready or not).
func (*BufferQueue) Next ¶
func (b *BufferQueue) Next() *NodeQueue
Next returns the next NodeQueue in round robin order.
func (*BufferQueue) NodeIDs ¶
func (b *BufferQueue) NodeIDs() []identity.ID
NodeIDs returns the nodeIDs of all nodes.
func (*BufferQueue) NodeQueue ¶
func (b *BufferQueue) NodeQueue(nodeID identity.ID) *NodeQueue
NodeQueue returns the queue for the corresponding node.
func (*BufferQueue) NumActiveNodes ¶
func (b *BufferQueue) NumActiveNodes() int
NumActiveNodes returns the number of active nodes in b.
func (*BufferQueue) PopFront ¶
func (b *BufferQueue) PopFront() Element
PopFront removes the first ready message from the queue of the current node.
func (*BufferQueue) Ready ¶
func (b *BufferQueue) Ready(msg Element) bool
Ready marks a previously submitted message as ready to be scheduled.
func (*BufferQueue) RemoveNode ¶
func (b *BufferQueue) RemoveNode(nodeID identity.ID)
RemoveNode removes all messages (submitted and ready) for the given node.
func (*BufferQueue) Size ¶
func (b *BufferQueue) Size() int
Size returns the total size (in bytes) of all messages in b.
func (*BufferQueue) Submit ¶
func (b *BufferQueue) Submit(msg Element, rep float64) error
Submit submits a message.
func (*BufferQueue) Unsubmit ¶
func (b *BufferQueue) Unsubmit(msg Element) bool
Unsubmit removes a message from the submitted messages. If that message is already marked as ready, Unsubmit has no effect.
type Element ¶
type Element interface { // IDBytes returns the ID of an Element as a byte slice. IDBytes() []byte // Size returns the size of the element. Size() int // IssuerPublicKey returns the issuer public key of the element. IssuerPublicKey() ed25519.PublicKey // IssuingTime returns the issuing time of the message. IssuingTime() time.Time }
Element represents the generic interface for an message in NodeQueue.
type ElementHeap ¶
type ElementHeap []Element
ElementHeap holds a heap of messages with respect to their IssuingTime.
func (ElementHeap) Len ¶
func (h ElementHeap) Len() int
Len is the number of elements in the collection.
func (ElementHeap) Less ¶
func (h ElementHeap) Less(i, j int) bool
Less reports whether the element with index i must sort before the element with index j.
func (*ElementHeap) Pop ¶
func (h *ElementHeap) Pop() interface{}
Pop removes and returns element with index Len() - 1.
func (*ElementHeap) Push ¶
func (h *ElementHeap) Push(x interface{})
Push adds x as element with index Len(). It panics if x is not Element.
func (ElementHeap) Swap ¶
func (h ElementHeap) Swap(i, j int)
Swap swaps the elements with indexes i and j.
type ElementID ¶
type ElementID [ElementIDLength]byte
ElementID defines the ID of element.
func ElementIDFromBytes ¶
ElementIDFromBytes converts byte array to an ElementID.
type NodeQueue ¶
type NodeQueue struct {
// contains filtered or unexported fields
}
NodeQueue keeps the submitted messages of a node
func NewNodeQueue ¶
NewNodeQueue returns a new NodeQueue
func (*NodeQueue) Size ¶
Size returns the total size of the messages in the queue. This function is thread-safe.