Documentation ¶
Index ¶
- func Add(db database.KeyValueWriterDeleter, tree *Tree, lastAcceptedHeight uint64, ...) (bool, error)
- func DeleteBlock(db database.KeyValueDeleter, height uint64) error
- func DeleteInterval(db database.KeyValueDeleter, upperBound uint64) error
- func GetBlock(db database.KeyValueReader, height uint64) ([]byte, error)
- func GetBlockIterator(db database.Iteratee) database.Iterator
- func GetBlockIteratorWithStart(db database.Iteratee, height uint64) database.Iterator
- func PutBlock(db database.KeyValueWriter, height uint64, bytes []byte) error
- func PutInterval(db database.KeyValueWriter, upperBound uint64, lowerBound uint64) error
- func Remove(db database.KeyValueWriterDeleter, tree *Tree, height uint64) error
- type Interval
- type Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add( db database.KeyValueWriterDeleter, tree *Tree, lastAcceptedHeight uint64, height uint64, blkBytes []byte, ) (bool, error)
Add the block to the tree and return if the parent block should be fetched, but wasn't desired before.
func DeleteBlock ¶
func DeleteBlock(db database.KeyValueDeleter, height uint64) error
func DeleteInterval ¶
func DeleteInterval(db database.KeyValueDeleter, upperBound uint64) error
func GetBlockIterator ¶
GetBlockIterator returns a block iterator that will produce values corresponding to persisted blocks in order of increasing height.
func GetBlockIteratorWithStart ¶
GetBlockIterator returns a block iterator that will produce values corresponding to persisted blocks in order of increasing height starting at [height].
func PutInterval ¶
func PutInterval(db database.KeyValueWriter, upperBound uint64, lowerBound uint64) error
Types ¶
type Interval ¶
func (*Interval) AdjacentToLowerBound ¶
AdjacentToLowerBound returns true if height is 1 less than lowerBound.
func (*Interval) AdjacentToUpperBound ¶
AdjacentToUpperBound returns true if height is 1 greater than upperBound.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree implements a set of numbers by tracking intervals. It supports adding and removing new values. It also allows checking if a value is included in the set.
Tree is more space efficient than a map implementation if the values that it contains are continuous. The tree takes O(n) space where n is the number of continuous ranges that have been inserted into the tree.
Add, Remove, and Contains all run in O(log n) where n is the number of continuous ranges that have been inserted into the tree.
func NewTree ¶
NewTree creates a new interval tree from the provided database.
It is assumed that persisted intervals are non-overlapping. Providing a database with overlapping intervals will result in undefined behavior of the structure.