headerlist

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: ISC, MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoundedMemoryChain

type BoundedMemoryChain struct {
	// contains filtered or unexported fields
}

func NewBoundedMemoryChain

func NewBoundedMemoryChain(
	maxNodes uint32) *BoundedMemoryChain

NewBoundedMemoryChain returns a new instance of the BoundedMemoryChain with a target max number of nodes.

func (*BoundedMemoryChain) Back

func (b *BoundedMemoryChain) Back() *Node

Back returns the end of the chain. If the chain is empty, then this return a pointer to a nil node.

NOTE: Part of the Chain interface.

func (*BoundedMemoryChain) Front

func (b *BoundedMemoryChain) Front() *Node

Front returns the head of the chain. If the chain is empty, then this returns a pointer to a nil node.

NOTE: Part of the Chain interface.

func (*BoundedMemoryChain) PushBack

func (b *BoundedMemoryChain) PushBack(n Node) *Node

PushBack will push a new entry to the end of the chain. The entry added to the chain is also returned in place. As the chain is bounded, if the length of the chain is exceeded, then the front of the chain will be walked forward one element.

NOTE: Part of the Chain interface.

func (*BoundedMemoryChain) ResetHeaderState

func (b *BoundedMemoryChain) ResetHeaderState(n Node)

ResetHeaderState resets the state of all nodes. After this method, it will be as if the chain was just newly created.

NOTE: Part of the Chain interface.

type Chain

type Chain interface {

	// be as if the chain was just newly created.
	ResetHeaderState(Node)

	// return a pointer to a nil node.
	Back() *Node

	// this returns a  pointer to a nil node.
	Front() *Node

	// added to the chain is also returned in place.
	PushBack(Node) *Node
}

type Node

type Node struct {

	// Height is the height of this node within the main chain.
	Height int32

	// Header is the header that this node represents.
	Header wire.BlockHeader
	// contains filtered or unexported fields
}

func (*Node) Prev

func (n *Node) Prev() *Node

Prev attempts to access the prior node within the header chain relative to this node. If this is the start of the chain, then this method will return nil.

Jump to

Keyboard shortcuts

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