Documentation ¶
Index ¶
- func ForEach(b *BPT, fn func(key *record.Key, hash []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 *record.Key) error
- func (b *BPT) Get(key *record.Key) ([]byte, error)
- func (b *BPT) GetReceipt(key *record.Key) (*merkle.Receipt, error)
- func (b *BPT) GetRootHash() ([32]byte, error)
- func (b *BPT) Insert(key *record.Key, value []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) SetParams(p Parameters) error
- func (b *BPT) Walk(opts database.WalkOptions, fn database.WalkFunc) error
- type Iterator
- type KeyValuePair
- type Parameters
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 (*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 constructs a receipt for the current state for the given key.
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.
func (*BPT) SetParams ¶ added in v1.4.0
func (b *BPT) SetParams(p Parameters) error
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 Parameters ¶ added in v1.4.0
func (*Parameters) Copy ¶ added in v1.4.0
func (v *Parameters) Copy() *Parameters
Copy returns a copy of the Parameters.
func (*Parameters) Equal ¶ added in v1.4.0
func (v *Parameters) Equal(u *Parameters) bool
EqualParameters returns true if V is equal to U.