queue

package
v0.10.1-consensus-desr... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2020 License: AGPL-3.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blockify

type Blockify interface {
	flow.Entity
	Height() uint64
	ParentID() flow.Identifier
}

Blockify becuase Blocker seems a bit off. Make items behave like a block, so it can be queued

type Node

type Node struct {
	Item     Blockify
	Children []*Node
}

type Queue

type Queue struct {
	Head    *Node
	Highest *Node
	Nodes   map[flow.Identifier]*Node
}

Queue is a fork-aware queue/tree of blocks for use in execution Node, where parallel forks can be processed simultaneously. For fast lookup which is predicted to be common case all nodes are kept as one queue, which is expected to split into separate queues once a fork (multiple children) is reached. Note that this is not a thread-safe structure and external synchronisation is required to use in concurrent environment

func NewQueue

func NewQueue(blockify Blockify) *Queue

func (*Queue) Attach

func (q *Queue) Attach(other *Queue) error

Attach joins two queues together, fails if new queue head cannot be attached

func (*Queue) Checksum

func (q *Queue) Checksum() flow.Identifier

func (*Queue) Dismount

func (q *Queue) Dismount() (Blockify, []*Queue)

Dismount removes the head element, returns it and it's children as new queues

func (*Queue) Height

func (q *Queue) Height() uint64

Returns difference between lowest and highest element in the queue

func (*Queue) ID

func (q *Queue) ID() flow.Identifier

func (*Queue) Size

func (q *Queue) Size() int

Size returns number of elements in the queue

func (*Queue) TryAdd

func (q *Queue) TryAdd(executableBlock Blockify) bool

TryAdd tries to add a new Node to the queue and returns if the operation has been successful A node can only be added if the parent exists in the queue

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL