forkdb_multi_index

package
v0.0.0-...-e0ee87b Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ByBlockIdFunc = func(n BlockStatePtr) common.BlockIdType { return n.BlockId }
View Source
var ByBlockNumCompare = func(aBlock, bBlock ByBlockNumComposite) int {
	if aBlock.BlockNum != nil && bBlock.BlockNum != nil {
		if *aBlock.BlockNum < *bBlock.BlockNum {
			return -1
		} else if *aBlock.BlockNum > *bBlock.BlockNum {
			return 1
		}
	}

	if aBlock.InCurrentChain != nil && bBlock.InCurrentChain != nil {
		if *aBlock.InCurrentChain && !*bBlock.InCurrentChain {
			return -1
		} else if !*aBlock.InCurrentChain && *bBlock.InCurrentChain {
			return 1
		}
	}

	return 0
}
View Source
var ByBlockNumFunc = func(n BlockStatePtr) ByBlockNumComposite { return ByBlockNumComposite{&n.BlockNum, &n.InCurrentChain} }
View Source
var ByLibBlockNumCompare = func(aBlock, bBlock ByLibBlockNumComposite) int {
	if aBlock.DposIrreversibleBlocknum != nil && bBlock.DposIrreversibleBlocknum != nil {
		if *aBlock.DposIrreversibleBlocknum > *bBlock.DposIrreversibleBlocknum {
			return -1
		} else if *aBlock.DposIrreversibleBlocknum < *bBlock.DposIrreversibleBlocknum {
			return 1
		}
	}

	if aBlock.BftIrreversibleBlocknum != nil && bBlock.BftIrreversibleBlocknum != nil {
		if *aBlock.BftIrreversibleBlocknum > *bBlock.BftIrreversibleBlocknum {
			return -1
		} else if *aBlock.BftIrreversibleBlocknum < *bBlock.BftIrreversibleBlocknum {
			return 1
		}
	}

	if aBlock.BlockNum != nil && bBlock.BlockNum != nil {
		if *aBlock.BlockNum > *bBlock.BlockNum {
			return -1
		} else if *aBlock.BlockNum < *bBlock.BlockNum {
			return 1
		}
	}

	return 0
}
View Source
var ByLibBlockNumFunc = func(n BlockStatePtr) ByLibBlockNumComposite {
	return ByLibBlockNumComposite{&n.DposIrreversibleBlocknum, &n.BftIrreversibleBlocknum, &n.BlockNum}
}
View Source
var ByPrevCompare = crypto.Sha256Compare
View Source
var ByPrevFunc = func(n BlockStatePtr) common.BlockIdType { return n.Header.Previous }

Functions

This section is empty.

Types

type BlockStatePtr

type BlockStatePtr = *types.BlockState

type ByBlockId

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

func (*ByBlockId) Each

func (i *ByBlockId) Each(f func(key common.BlockIdType, obj BlockStatePtr))

func (*ByBlockId) Empty

func (i *ByBlockId) Empty() bool

func (*ByBlockId) End

func (i *ByBlockId) End() IteratorByBlockId

func (*ByBlockId) Erase

func (i *ByBlockId) Erase(iter IteratorByBlockId)

func (*ByBlockId) Find

func (*ByBlockId) GetFinalIndex

func (i *ByBlockId) GetFinalIndex() interface{}

func (*ByBlockId) GetSuperIndex

func (i *ByBlockId) GetSuperIndex() interface{}

func (*ByBlockId) Insert

func (*ByBlockId) Modify

func (i *ByBlockId) Modify(iter IteratorByBlockId, mod func(*BlockStatePtr)) bool

func (*ByBlockId) Size

func (i *ByBlockId) Size() int

func (*ByBlockId) Values

func (i *ByBlockId) Values() []BlockStatePtr

type ByBlockIdNode

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

func (*ByBlockIdNode) GetFinalNode

func (n *ByBlockIdNode) GetFinalNode() interface{}

func (*ByBlockIdNode) GetSuperNode

func (n *ByBlockIdNode) GetSuperNode() interface{}

type ByBlockNum

type ByBlockNum struct {
	Root *ByBlockNumNode
	// contains filtered or unexported fields
}

OrderedIndex holds elements of the red-black tree

func (*ByBlockNum) Begin

func (tree *ByBlockNum) Begin() IteratorByBlockNum

func (*ByBlockNum) Clear

func (tree *ByBlockNum) Clear()

Clear removes all nodes from the tree.

func (*ByBlockNum) Empty

func (tree *ByBlockNum) Empty() bool

Empty returns true if tree does not contain any nodes

func (*ByBlockNum) End

func (tree *ByBlockNum) End() IteratorByBlockNum

func (*ByBlockNum) Erase

func (tree *ByBlockNum) Erase(iter IteratorByBlockNum) (itr IteratorByBlockNum)

func (*ByBlockNum) Erases

func (tree *ByBlockNum) Erases(first, last IteratorByBlockNum)

func (*ByBlockNum) Find

Get searches the node in the tree by key and returns its value or nil if key is not found in tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*ByBlockNum) Insert

func (tree *ByBlockNum) Insert(v BlockStatePtr) (IteratorByBlockNum, bool)

func (*ByBlockNum) Iterator

func (tree *ByBlockNum) Iterator() IteratorByBlockNum

Iterator returns a stateful iterator whose elements are key/value pairs.

func (*ByBlockNum) Keys

func (tree *ByBlockNum) Keys() []ByBlockNumComposite

Keys returns all keys in-order

func (*ByBlockNum) Left

func (tree *ByBlockNum) Left() *ByBlockNumNode

Left returns the left-most (min) node or nil if tree is empty.

func (*ByBlockNum) LowerBound

func (tree *ByBlockNum) LowerBound(key ByBlockNumComposite) IteratorByBlockNum

LowerBound returns an iterator pointing to the first element that is not less than the given key. Complexity: O(log N).

func (*ByBlockNum) Modify

func (tree *ByBlockNum) Modify(iter IteratorByBlockNum, mod func(*BlockStatePtr)) bool

func (*ByBlockNum) Remove

func (tree *ByBlockNum) Remove(key ByBlockNumComposite)

Remove remove the node from the tree by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*ByBlockNum) Right

func (tree *ByBlockNum) Right() *ByBlockNumNode

Right returns the right-most (max) node or nil if tree is empty.

func (*ByBlockNum) Size

func (tree *ByBlockNum) Size() int

Size returns number of nodes in the tree.

func (*ByBlockNum) String

func (tree *ByBlockNum) String() string

String returns a string representation of container

func (*ByBlockNum) UpperBound

func (tree *ByBlockNum) UpperBound(key ByBlockNumComposite) IteratorByBlockNum

UpperBound returns an iterator pointing to the first element that is greater than the given key. Complexity: O(log N).

func (*ByBlockNum) Values

func (tree *ByBlockNum) Values() []BlockStatePtr

Values returns all values in-order based on the key.

type ByBlockNumComposite

type ByBlockNumComposite struct {
	BlockNum       *uint32
	InCurrentChain *bool
}

type ByBlockNumNode

type ByBlockNumNode struct {
	Key ByBlockNumComposite

	Left   *ByBlockNumNode
	Right  *ByBlockNumNode
	Parent *ByBlockNumNode
	// contains filtered or unexported fields
}

OrderedIndexNode is a single element within the tree

func (*ByBlockNumNode) String

func (node *ByBlockNumNode) String() string

type ByLibBlockNum

type ByLibBlockNum struct {
	Root *ByLibBlockNumNode
	// contains filtered or unexported fields
}

OrderedIndex holds elements of the red-black tree

func (*ByLibBlockNum) Begin

func (tree *ByLibBlockNum) Begin() IteratorByLibBlockNum

func (*ByLibBlockNum) Clear

func (tree *ByLibBlockNum) Clear()

Clear removes all nodes from the tree.

func (*ByLibBlockNum) Empty

func (tree *ByLibBlockNum) Empty() bool

Empty returns true if tree does not contain any nodes

func (*ByLibBlockNum) End

func (*ByLibBlockNum) Erase

func (*ByLibBlockNum) Erases

func (tree *ByLibBlockNum) Erases(first, last IteratorByLibBlockNum)

func (*ByLibBlockNum) Find

Get searches the node in the tree by key and returns its value or nil if key is not found in tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*ByLibBlockNum) Insert

func (*ByLibBlockNum) Iterator

func (tree *ByLibBlockNum) Iterator() IteratorByLibBlockNum

Iterator returns a stateful iterator whose elements are key/value pairs.

func (*ByLibBlockNum) Keys

func (tree *ByLibBlockNum) Keys() []ByLibBlockNumComposite

Keys returns all keys in-order

func (*ByLibBlockNum) Left

func (tree *ByLibBlockNum) Left() *ByLibBlockNumNode

Left returns the left-most (min) node or nil if tree is empty.

func (*ByLibBlockNum) LowerBound

LowerBound returns an iterator pointing to the first element that is not less than the given key. Complexity: O(log N).

func (*ByLibBlockNum) Modify

func (tree *ByLibBlockNum) Modify(iter IteratorByLibBlockNum, mod func(*BlockStatePtr)) bool

func (*ByLibBlockNum) Remove

func (tree *ByLibBlockNum) Remove(key ByLibBlockNumComposite)

Remove remove the node from the tree by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*ByLibBlockNum) Right

func (tree *ByLibBlockNum) Right() *ByLibBlockNumNode

Right returns the right-most (max) node or nil if tree is empty.

func (*ByLibBlockNum) Size

func (tree *ByLibBlockNum) Size() int

Size returns number of nodes in the tree.

func (*ByLibBlockNum) String

func (tree *ByLibBlockNum) String() string

String returns a string representation of container

func (*ByLibBlockNum) UpperBound

UpperBound returns an iterator pointing to the first element that is greater than the given key. Complexity: O(log N).

func (*ByLibBlockNum) Values

func (tree *ByLibBlockNum) Values() []BlockStatePtr

Values returns all values in-order based on the key.

type ByLibBlockNumComposite

type ByLibBlockNumComposite struct {
	DposIrreversibleBlocknum *uint32
	BftIrreversibleBlocknum  *uint32
	BlockNum                 *uint32
}

type ByLibBlockNumNode

type ByLibBlockNumNode struct {
	Key ByLibBlockNumComposite

	Left   *ByLibBlockNumNode
	Right  *ByLibBlockNumNode
	Parent *ByLibBlockNumNode
	// contains filtered or unexported fields
}

OrderedIndexNode is a single element within the tree

func (*ByLibBlockNumNode) String

func (node *ByLibBlockNumNode) String() string

type ByPrev

type ByPrev struct {
	Root *ByPrevNode
	// contains filtered or unexported fields
}

OrderedIndex holds elements of the red-black tree

func (*ByPrev) Begin

func (tree *ByPrev) Begin() IteratorByPrev

func (*ByPrev) Clear

func (tree *ByPrev) Clear()

Clear removes all nodes from the tree.

func (*ByPrev) Empty

func (tree *ByPrev) Empty() bool

Empty returns true if tree does not contain any nodes

func (*ByPrev) End

func (tree *ByPrev) End() IteratorByPrev

func (*ByPrev) Erase

func (tree *ByPrev) Erase(iter IteratorByPrev) (itr IteratorByPrev)

func (*ByPrev) Erases

func (tree *ByPrev) Erases(first, last IteratorByPrev)

func (*ByPrev) Find

func (tree *ByPrev) Find(key common.BlockIdType) IteratorByPrev

Get searches the node in the tree by key and returns its value or nil if key is not found in tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*ByPrev) Insert

func (tree *ByPrev) Insert(v BlockStatePtr) (IteratorByPrev, bool)

func (*ByPrev) Iterator

func (tree *ByPrev) Iterator() IteratorByPrev

Iterator returns a stateful iterator whose elements are key/value pairs.

func (*ByPrev) Keys

func (tree *ByPrev) Keys() []common.BlockIdType

Keys returns all keys in-order

func (*ByPrev) Left

func (tree *ByPrev) Left() *ByPrevNode

Left returns the left-most (min) node or nil if tree is empty.

func (*ByPrev) LowerBound

func (tree *ByPrev) LowerBound(key common.BlockIdType) IteratorByPrev

LowerBound returns an iterator pointing to the first element that is not less than the given key. Complexity: O(log N).

func (*ByPrev) Modify

func (tree *ByPrev) Modify(iter IteratorByPrev, mod func(*BlockStatePtr)) bool

func (*ByPrev) Remove

func (tree *ByPrev) Remove(key common.BlockIdType)

Remove remove the node from the tree by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*ByPrev) Right

func (tree *ByPrev) Right() *ByPrevNode

Right returns the right-most (max) node or nil if tree is empty.

func (*ByPrev) Size

func (tree *ByPrev) Size() int

Size returns number of nodes in the tree.

func (*ByPrev) String

func (tree *ByPrev) String() string

String returns a string representation of container

func (*ByPrev) UpperBound

func (tree *ByPrev) UpperBound(key common.BlockIdType) IteratorByPrev

UpperBound returns an iterator pointing to the first element that is greater than the given key. Complexity: O(log N).

func (*ByPrev) Values

func (tree *ByPrev) Values() []BlockStatePtr

Values returns all values in-order based on the key.

type ByPrevNode

type ByPrevNode struct {
	Key common.BlockIdType

	Left   *ByPrevNode
	Right  *ByPrevNode
	Parent *ByPrevNode
	// contains filtered or unexported fields
}

OrderedIndexNode is a single element within the tree

func (*ByPrevNode) String

func (node *ByPrevNode) String() string

type IteratorByBlockId

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

func (IteratorByBlockId) HasNext

func (iter IteratorByBlockId) HasNext() bool

func (IteratorByBlockId) IsEnd

func (iter IteratorByBlockId) IsEnd() bool

func (IteratorByBlockId) Value

func (iter IteratorByBlockId) Value() (v BlockStatePtr)

type IteratorByBlockNum

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

Iterator holding the iterator's state

func (*IteratorByBlockNum) Begin

func (iterator *IteratorByBlockNum) Begin()

Begin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.

func (*IteratorByBlockNum) Delete

func (iterator *IteratorByBlockNum) Delete()

Delete remove the node which pointed by the iterator Modifies the state of the iterator.

func (*IteratorByBlockNum) End

func (iterator *IteratorByBlockNum) End()

End moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.

func (IteratorByBlockNum) HasNext

func (iterator IteratorByBlockNum) HasNext() bool

func (*IteratorByBlockNum) HasPrev

func (iterator *IteratorByBlockNum) HasPrev() bool

func (IteratorByBlockNum) IsBegin

func (iterator IteratorByBlockNum) IsBegin() bool

func (IteratorByBlockNum) IsEnd

func (iterator IteratorByBlockNum) IsEnd() bool

func (IteratorByBlockNum) Key

func (iterator IteratorByBlockNum) Key() ByBlockNumComposite

Key returns the current element's key. Does not modify the state of the iterator.

func (*IteratorByBlockNum) Next

func (iterator *IteratorByBlockNum) Next() bool

Next moves the iterator to the next element and returns true if there was a next element in the container. If Next() returns true, then next element's key and value can be retrieved by Key() and Value(). If Next() was called for the first time, then it will point the iterator to the first element if it exists. Modifies the state of the iterator.

func (*IteratorByBlockNum) Prev

func (iterator *IteratorByBlockNum) Prev() bool

Prev moves the iterator to the previous element and returns true if there was a previous element in the container. If Prev() returns true, then previous element's key and value can be retrieved by Key() and Value(). Modifies the state of the iterator.

func (IteratorByBlockNum) Value

func (iterator IteratorByBlockNum) Value() BlockStatePtr

Value returns the current element's value. Does not modify the state of the iterator.

type IteratorByLibBlockNum

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

Iterator holding the iterator's state

func (*IteratorByLibBlockNum) Begin

func (iterator *IteratorByLibBlockNum) Begin()

Begin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.

func (*IteratorByLibBlockNum) Delete

func (iterator *IteratorByLibBlockNum) Delete()

Delete remove the node which pointed by the iterator Modifies the state of the iterator.

func (*IteratorByLibBlockNum) End

func (iterator *IteratorByLibBlockNum) End()

End moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.

func (IteratorByLibBlockNum) HasNext

func (iterator IteratorByLibBlockNum) HasNext() bool

func (*IteratorByLibBlockNum) HasPrev

func (iterator *IteratorByLibBlockNum) HasPrev() bool

func (IteratorByLibBlockNum) IsBegin

func (iterator IteratorByLibBlockNum) IsBegin() bool

func (IteratorByLibBlockNum) IsEnd

func (iterator IteratorByLibBlockNum) IsEnd() bool

func (IteratorByLibBlockNum) Key

Key returns the current element's key. Does not modify the state of the iterator.

func (*IteratorByLibBlockNum) Next

func (iterator *IteratorByLibBlockNum) Next() bool

Next moves the iterator to the next element and returns true if there was a next element in the container. If Next() returns true, then next element's key and value can be retrieved by Key() and Value(). If Next() was called for the first time, then it will point the iterator to the first element if it exists. Modifies the state of the iterator.

func (*IteratorByLibBlockNum) Prev

func (iterator *IteratorByLibBlockNum) Prev() bool

Prev moves the iterator to the previous element and returns true if there was a previous element in the container. If Prev() returns true, then previous element's key and value can be retrieved by Key() and Value(). Modifies the state of the iterator.

func (IteratorByLibBlockNum) Value

func (iterator IteratorByLibBlockNum) Value() BlockStatePtr

Value returns the current element's value. Does not modify the state of the iterator.

type IteratorByPrev

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

Iterator holding the iterator's state

func (*IteratorByPrev) Begin

func (iterator *IteratorByPrev) Begin()

Begin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.

func (*IteratorByPrev) Delete

func (iterator *IteratorByPrev) Delete()

Delete remove the node which pointed by the iterator Modifies the state of the iterator.

func (*IteratorByPrev) End

func (iterator *IteratorByPrev) End()

End moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.

func (IteratorByPrev) HasNext

func (iterator IteratorByPrev) HasNext() bool

func (*IteratorByPrev) HasPrev

func (iterator *IteratorByPrev) HasPrev() bool

func (IteratorByPrev) IsBegin

func (iterator IteratorByPrev) IsBegin() bool

func (IteratorByPrev) IsEnd

func (iterator IteratorByPrev) IsEnd() bool

func (IteratorByPrev) Key

func (iterator IteratorByPrev) Key() common.BlockIdType

Key returns the current element's key. Does not modify the state of the iterator.

func (*IteratorByPrev) Next

func (iterator *IteratorByPrev) Next() bool

Next moves the iterator to the next element and returns true if there was a next element in the container. If Next() returns true, then next element's key and value can be retrieved by Key() and Value(). If Next() was called for the first time, then it will point the iterator to the first element if it exists. Modifies the state of the iterator.

func (*IteratorByPrev) Prev

func (iterator *IteratorByPrev) Prev() bool

Prev moves the iterator to the previous element and returns true if there was a previous element in the container. If Prev() returns true, then previous element's key and value can be retrieved by Key() and Value(). Modifies the state of the iterator.

func (IteratorByPrev) Value

func (iterator IteratorByPrev) Value() BlockStatePtr

Value returns the current element's value. Does not modify the state of the iterator.

type MultiIndex

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

func NewMultiIndex

func NewMultiIndex() *MultiIndex

func (*MultiIndex) Clear

func (m *MultiIndex) Clear()

func (*MultiIndex) Erase

func (m *MultiIndex) Erase(iter multiindex.IteratorType)

func (*MultiIndex) GetByBlockId

func (m *MultiIndex) GetByBlockId() *ByBlockId

func (*MultiIndex) GetByBlockNum

func (m *MultiIndex) GetByBlockNum() *ByBlockNum

func (*MultiIndex) GetByLibBlockNum

func (m *MultiIndex) GetByLibBlockNum() *ByLibBlockNum

func (*MultiIndex) GetByPrev

func (m *MultiIndex) GetByPrev() *ByPrev

func (*MultiIndex) GetFinalIndex

func (m *MultiIndex) GetFinalIndex() interface{}

func (*MultiIndex) GetIndex

func (m *MultiIndex) GetIndex() interface{}

func (*MultiIndex) GetSuperIndex

func (m *MultiIndex) GetSuperIndex() interface{}

method for MultiIndex

func (*MultiIndex) Insert

func (m *MultiIndex) Insert(v BlockStatePtr) bool

func (*MultiIndex) Modify

func (m *MultiIndex) Modify(iter multiindex.IteratorType, mod func(*BlockStatePtr)) bool

func (*MultiIndex) Size

func (m *MultiIndex) Size() int

type MultiIndexBase

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

/ IndexBase

func (*MultiIndexBase) GetFinalIndex

func (i *MultiIndexBase) GetFinalIndex() interface{}

func (*MultiIndexBase) GetSuperIndex

func (i *MultiIndexBase) GetSuperIndex() interface{}

type MultiIndexBaseNode

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

type MultiIndexNode

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

func (*MultiIndexNode) GetFinalNode

func (n *MultiIndexNode) GetFinalNode() interface{}

func (*MultiIndexNode) GetSuperNode

func (n *MultiIndexNode) GetSuperNode() interface{}

Jump to

Keyboard shortcuts

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