headerlist

package
v0.4.16 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2021 License: Unlicense, MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check added in v0.4.14

func Check(err error) bool

func Debug added in v0.4.14

func Debug(a ...interface{})

func Debugc added in v0.4.14

func Debugc(fn func() string)

func Debugf added in v0.4.14

func Debugf(format string, a ...interface{})

func Debugs added in v0.4.14

func Debugs(a interface{})

func Error added in v0.4.14

func Error(a ...interface{})

func Errorc added in v0.4.14

func Errorc(fn func() string)

func Errorf added in v0.4.14

func Errorf(format string, a ...interface{})

func Errors added in v0.4.14

func Errors(a interface{})

func Fatal added in v0.4.14

func Fatal(a ...interface{})

func Fatalc added in v0.4.14

func Fatalc(fn func() string)

func Fatalf added in v0.4.14

func Fatalf(format string, a ...interface{})

func Fatals added in v0.4.14

func Fatals(a interface{})

func Info added in v0.4.14

func Info(a ...interface{})

func Infoc added in v0.4.14

func Infoc(fn func() string)

func Infof added in v0.4.14

func Infof(format string, a ...interface{})

func Infos added in v0.4.14

func Infos(a interface{})

func Trace added in v0.4.14

func Trace(a ...interface{})

func Tracec added in v0.4.14

func Tracec(fn func() string)

func Tracef added in v0.4.14

func Tracef(format string, a ...interface{})

func Traces added in v0.4.14

func Traces(a interface{})

func Warn added in v0.4.14

func Warn(a ...interface{})

func Warnc added in v0.4.14

func Warnc(fn func() string)

func Warnf added in v0.4.14

func Warnf(format string, a ...interface{})

func Warns added in v0.4.14

func Warns(a interface{})

Types

type BoundedMemoryChain

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

BoundedMemoryChain is an implementation of the headerlist.Chain interface which has a bounded size. The chain will be stored purely in memory. This is useful for enforcing that only the past N headers are stored in memory, or even as the primary header store. If an element inserted to the end of the chain exceeds the size limit, then the head of the chain will be moved forward removing a single entry from the head of the chain.

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 {
	// ResetHeaderState resets the state of all nodes. After this method, it will be as if the chain was just newly
	// created.
	ResetHeaderState(Node)
	// Back returns the end of the chain. If the chain is empty, then this return a pointer to a nil node.
	Back() *Node
	// Front returns the head of the chain. If the chain is empty, then this returns a pointer to a nil node.
	Front() *Node
	// PushBack will push a new entry to the end of the chain. The entry added to the chain is also returned in place.
	PushBack(Node) *Node
}

Chain is an interface that stores a list of Nodes. Each node represents a header in the main chain and also includes a height along with it. This is meant to serve as a replacement to list.List which provides similar functionality, but allows implementations to use custom storage backends and semantics.

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
}

Node is a node within the Chain. Each node stores a header as well as a height. Nodes can also be used to traverse the chain backwards via their Prev() method.

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