Documentation ¶
Index ¶
- func CleanHistory(ctx context.Context, back *Backend, startCommitNum, limitCommitNum uint32) error
- type Backend
- type Cache
- func (c *Cache) AddNodeBlob(name string, seq sequence, path []byte, blob []byte, isCommitting bool)
- func (c *Cache) AddRootNode(name string, n trie.Node) bool
- func (c *Cache) GetNodeBlob(name string, seq sequence, path []byte, peek bool, dst []byte) []byte
- func (c *Cache) GetRootNode(name string, seq uint64, peek bool) (trie.Node, bool)
- type LeafBank
- type LeafRecord
- type LeafUpdater
- type Trie
- func (t *Trie) Copy() *Trie
- func (t *Trie) DumpLeaves(ctx context.Context, baseCommitNum, targetCommitNum uint32, ...) error
- func (t *Trie) DumpNodes(ctx context.Context, baseCommitNum uint32, handleLeaf func(*trie.Leaf)) error
- func (t *Trie) FastGet(key []byte, steadyCommitNum uint32) ([]byte, []byte, error)
- func (t *Trie) Get(key []byte) ([]byte, []byte, error)
- func (t *Trie) Name() string
- func (t *Trie) NodeIterator(start []byte, baseCommitNum uint32) trie.NodeIterator
- func (t *Trie) SetNoFillCache(b bool)
- func (t *Trie) Stage(newCommitNum, newDistinctNum uint32) (root thor.Bytes32, commit func() error)
- func (t *Trie) Update(key, val, meta []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backend ¶
type Backend struct { Store kv.Store Cache *Cache LeafBank *LeafBank HistSpace, DedupedSpace byte HistPtnFactor, DedupedPtnFactor uint32 CachedNodeTTL uint16 }
Backend is the backend of the trie.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is the cache layer for trie.
func (*Cache) AddNodeBlob ¶
AddNodeBlob adds node blob into the cache.
func (*Cache) AddRootNode ¶
AddRootNode add the root node into the cache.
func (*Cache) GetNodeBlob ¶
GetNodeBlob returns the cached node blob.
type LeafBank ¶
type LeafBank struct {
// contains filtered or unexported fields
}
LeafBank records accumulated trie leaves to help accelerate trie leaf access according to VIP-212.
func NewLeafBank ¶
NewLeafBank creates a new LeafBank instance. The slotCap indicates the capacity of cached per-trie slots.
func (*LeafBank) LogDeletions ¶
func (b *LeafBank) LogDeletions(putter kv.Putter, name string, keys []string, commitNum uint32) error
LogDeletions saves the journal of leaf-key deletions which issued by one trie-commit.
func (*LeafBank) Lookup ¶
func (b *LeafBank) Lookup(name string, leafKey []byte) (rec *LeafRecord, err error)
Lookup lookups a leaf record by the given leafKey for the trie named by name. LeafRecord.Leaf might be nil if the leaf can't be determined.
func (*LeafBank) NewUpdater ¶
func (b *LeafBank) NewUpdater(name string, baseCommitNum, targetCommitNum uint32) (*LeafUpdater, error)
NewUpdater creates a leaf-updater for a trie slot with the given name.
type LeafRecord ¶
type LeafRecord struct { *trie.Leaf CommitNum uint32 // which commit number the leaf was committed SlotCommitNum uint32 // up to which commit number this leaf is valid }
LeafRecord presents the queried leaf record.
type LeafUpdater ¶
type LeafUpdater struct {
// contains filtered or unexported fields
}
LeafUpdater helps to record trie leaves.
func (*LeafUpdater) Commit ¶
func (u *LeafUpdater) Commit() error
Commit commits updates into leafbank.
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie is the managed trie.
func New ¶
func New( back *Backend, name string, root thor.Bytes32, commitNum uint32, distinctNum uint32, nonCrypto bool, ) *Trie
New creates a managed trie.
func (*Trie) DumpLeaves ¶
func (t *Trie) DumpLeaves(ctx context.Context, baseCommitNum, targetCommitNum uint32, transform func(*trie.Leaf) *trie.Leaf) error
DumpLeaves dumps leaves in the range of [baseCommitNum, targetCommitNum] into leaf bank. transform transforms leaves before passing into leaf bank.
func (*Trie) DumpNodes ¶
func (t *Trie) DumpNodes(ctx context.Context, baseCommitNum uint32, handleLeaf func(*trie.Leaf)) error
DumpNodes dumps referenced nodes committed within [baseCommitNum, thisCommitNum], into the deduped space.
func (*Trie) FastGet ¶
FastGet uses a fast way to query the value for key stored in the trie. See VIP-212 for detail.
func (*Trie) Get ¶
Get returns the value for key stored in the trie. The value bytes must not be modified by the caller.
func (*Trie) NodeIterator ¶
func (t *Trie) NodeIterator(start []byte, baseCommitNum uint32) trie.NodeIterator
NodeIterator returns an iterator that returns nodes of the trie. Iteration starts at the key after the given start key
func (*Trie) SetNoFillCache ¶
SetNoFillCache enable or disable cache filling.
func (*Trie) Update ¶
Update associates key with value in the trie. Subsequent calls to Get will return value. If value has length zero, any existing value is deleted from the trie and calls to Get will return nil.
The value bytes must not be modified by the caller while they are stored in the trie.