Documentation ¶
Index ¶
- func ForEach(b *BPT, fn func(key record.KeyHash, hash [32]byte) error) error
- func LoadSnapshotV1(b *BPT, file ioutil2.SectionReader, ...) error
- func ReadSnapshotV1(file ioutil2.SectionReader, ...) error
- func SaveSnapshotV1(b *BPT, file io.WriteSeeker, ...) error
- type BPT
- func (b *BPT) Commit() error
- func (b *BPT) Delete(key [32]byte) error
- func (b *BPT) Get(key [32]byte) ([32]byte, error)
- func (b *BPT) GetReceipt(key [32]byte) (*merkle.Receipt, error)
- func (b *BPT) GetRootHash() ([32]byte, error)
- func (b *BPT) Insert(key, hash [32]byte) error
- func (b *BPT) IsDirty() bool
- func (b *BPT) Iterate(window int) *Iterator
- func (c *BPT) Key() *record.Key
- func (b *BPT) Resolve(key *database.Key) (database.Record, *database.Key, error)
- func (b *BPT) Walk(opts database.WalkOptions, fn database.WalkFunc) error
- type Iterator
- type KeyValuePair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadSnapshotV1 ¶
func LoadSnapshotV1(b *BPT, file ioutil2.SectionReader, storeState func(key storage.Key, hash [32]byte, reader ioutil2.SectionReader) error) error
LoadSnapshotV1 restores a snapshot to the BPT
func ReadSnapshotV1 ¶
func ReadSnapshotV1(file ioutil2.SectionReader, storeState func(key storage.Key, hash [32]byte, reader ioutil2.SectionReader) error) error
ReadSnapshotV1 reads a snapshot
func SaveSnapshotV1 ¶
func SaveSnapshotV1(b *BPT, file io.WriteSeeker, loadState func(key storage.Key, hash [32]byte) ([]byte, error)) error
SaveSnapshotV1 Saves a snapshot of the state of the BVN/DVN. 1) The first thing done is copy the entire BVN and persist it to disk 2) Then all the states are pulled from the database and persisted. As long as the BVN is captured in its entirety within a block, the states can be persisted over other blocks (as long as we don't delete any of those states
Snapshot Format:
8 byte count of nodes (NumNodes) [count of nodes]node -- each node is a Fixed length [count of nodes]value -- each value is variable length
node:
32 byte Key -- 8 byte offset from end of nodes to value 32 byte Hash -- Hash of the value of the BPT entry 8 byte offset -- from end of list of nodes to start of the value
value:
8 byte -- length of value n [length of value]byte -- the bytes of the value
Types ¶
type BPT ¶
type BPT struct {
// contains filtered or unexported fields
}
func New ¶
func New(parent database.Record, logger log.Logger, store database.Store, key *database.Key, label string) *BPT
New returns a new BPT.
func (*BPT) Delete ¶ added in v1.2.0
Delete removes the entry for the given key, if present. Delete may defer the actual update.
func (*BPT) GetReceipt ¶
GetReceipt Returns the receipt for the current state for the given chainID
func (*BPT) GetRootHash ¶
GetRootHash returns the root hash of the BPT, loading nodes, executing pending updates, and recalculating hashes if necessary.
func (*BPT) Insert ¶
Insert updates or inserts a hash for the given key. Insert may defer the actual update.
func (*BPT) Iterate ¶
Iterate returns an iterator that iterates over the BPT, reading N entries at a time where N = window. Iterate panics if window is negative or zero.
func (*BPT) Resolve ¶
Resolve implements database.Record.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator iterates over the BPT.
func (*Iterator) Next ¶
Next returns the next N results. Next returns false if there are no more results or if an error occurs. The caller must return Err after Next returns false to check for an error.
func (*Iterator) Value ¶ added in v1.2.0
func (it *Iterator) Value() []KeyValuePair
type KeyValuePair ¶
type KeyValuePair struct {
Key, Value [32]byte
}