Documentation ¶
Index ¶
- func Check(err error) bool
- func Debug(a ...interface{})
- func Debugc(fn func() string)
- func Debugf(format string, a ...interface{})
- func Debugs(a interface{})
- func Error(a ...interface{})
- func Errorc(fn func() string)
- func Errorf(format string, a ...interface{})
- func Errors(a interface{})
- func Fatal(a ...interface{})
- func Fatalc(fn func() string)
- func Fatalf(format string, a ...interface{})
- func Fatals(a interface{})
- func Info(a ...interface{})
- func Infoc(fn func() string)
- func Infof(format string, a ...interface{})
- func Infos(a interface{})
- func Trace(a ...interface{})
- func Tracec(fn func() string)
- func Tracef(format string, a ...interface{})
- func Traces(a interface{})
- func Warn(a ...interface{})
- func Warnc(fn func() string)
- func Warnf(format string, a ...interface{})
- func Warns(a interface{})
- type BoundedMemoryChain
- type Chain
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.