Documentation
¶
Overview ¶
Package blockbuffer is a simple heap like structure for keeping a few recent blocks in memory for averaging and analysis.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BigIntHeap ¶
BigIntHeap implement the heap interface for big Ints.
func (*BigIntHeap) Pop ¶
func (h *BigIntHeap) Pop() interface{}
Pop will remove the last element in the heap and return it.
func (*BigIntHeap) Push ¶
func (h *BigIntHeap) Push(x interface{})
Push will add an element to the heap.
func (BigIntHeap) Swap ¶
func (h BigIntHeap) Swap(i, j int)
Swap will exchange two elements in our heap.
type BlockBuffer ¶
type BlockBuffer struct {
// contains filtered or unexported fields
}
The BlockBuffer is a min-heap data structure to keep a set of recent blocks in memory.
func NewBlockBuffer ¶
func NewBlockBuffer(size uint) *BlockBuffer
NewBlockBuffer will return a heap that's constrained to the given size.
func (*BlockBuffer) GetBlock ¶
func (b *BlockBuffer) GetBlock(number uint64) (BufferedBlock, error)
GetBlock will return a block or an error if it doesn't exist.
func (*BlockBuffer) PutBlock ¶
func (b *BlockBuffer) PutBlock(block BufferedBlock) error
PutBlock will push a new block into the heap. If adding that block expand the heap beyond the max size, we'll delete the oldest block (based on number).
type BufferedBlock ¶
BufferedBlock is a way to abstract the block for queueing and sorting. The only thing we need is a block number in order to keep the blocks ordered.