Documentation ¶
Overview ¶
Package merkledb is a generated GoMock package.
Index ¶
- Constants
- Variables
- func New(ctx context.Context, db database.Database, config Config) (*merkleDB, error)
- type ChangeProof
- type ChangeProofer
- type Config
- type KeyChange
- type KeyValue
- type MerkleDB
- type MerkleRootGetter
- type MockMerkleDB
- func (m *MockMerkleDB) Close() error
- func (m *MockMerkleDB) CommitChangeProof(arg0 context.Context, arg1 *ChangeProof) error
- func (m *MockMerkleDB) CommitRangeProof(arg0 context.Context, arg1 []byte, arg2 *RangeProof) error
- func (m *MockMerkleDB) Compact(arg0, arg1 []byte) error
- func (m *MockMerkleDB) Delete(arg0 []byte) error
- func (m *MockMerkleDB) EXPECT() *MockMerkleDBMockRecorder
- func (m *MockMerkleDB) Get(arg0 []byte) ([]byte, error)
- func (m *MockMerkleDB) GetChangeProof(arg0 context.Context, arg1, arg2 ids.ID, arg3 []byte, ...) (*ChangeProof, error)
- func (m *MockMerkleDB) GetMerkleRoot(arg0 context.Context) (ids.ID, error)
- func (m *MockMerkleDB) GetProof(arg0 context.Context, arg1 []byte) (*Proof, error)
- func (m *MockMerkleDB) GetRangeProof(arg0 context.Context, arg1 []byte, arg2 maybe.Maybe[[]uint8], arg3 int) (*RangeProof, error)
- func (m *MockMerkleDB) GetRangeProofAtRoot(arg0 context.Context, arg1 ids.ID, arg2 []byte, arg3 maybe.Maybe[[]uint8], ...) (*RangeProof, error)
- func (m *MockMerkleDB) GetValue(arg0 context.Context, arg1 []byte) ([]byte, error)
- func (m *MockMerkleDB) GetValues(arg0 context.Context, arg1 [][]byte) ([][]byte, []error)
- func (m *MockMerkleDB) Has(arg0 []byte) (bool, error)
- func (m *MockMerkleDB) HealthCheck(arg0 context.Context) (interface{}, error)
- func (m *MockMerkleDB) Insert(arg0 context.Context, arg1, arg2 []byte) error
- func (m *MockMerkleDB) NewBatch() database.Batch
- func (m *MockMerkleDB) NewIterator() database.Iterator
- func (m *MockMerkleDB) NewIteratorWithPrefix(arg0 []byte) database.Iterator
- func (m *MockMerkleDB) NewIteratorWithStart(arg0 []byte) database.Iterator
- func (m *MockMerkleDB) NewIteratorWithStartAndPrefix(arg0, arg1 []byte) database.Iterator
- func (m *MockMerkleDB) NewPreallocatedView(arg0 int) (TrieView, error)
- func (m *MockMerkleDB) NewView() (TrieView, error)
- func (m *MockMerkleDB) Put(arg0, arg1 []byte) error
- func (m *MockMerkleDB) Remove(arg0 context.Context, arg1 []byte) error
- func (m *MockMerkleDB) VerifyChangeProof(arg0 context.Context, arg1 *ChangeProof, arg2 []byte, ...) error
- type MockMerkleDBMockRecorder
- func (mr *MockMerkleDBMockRecorder) Close() *gomock.Call
- func (mr *MockMerkleDBMockRecorder) CommitChangeProof(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) CommitRangeProof(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) Compact(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) Delete(arg0 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) Get(arg0 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) GetChangeProof(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) GetMerkleRoot(arg0 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) GetProof(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) GetRangeProof(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) GetRangeProofAtRoot(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) GetValue(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) GetValues(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) Has(arg0 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) HealthCheck(arg0 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) Insert(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) NewBatch() *gomock.Call
- func (mr *MockMerkleDBMockRecorder) NewIterator() *gomock.Call
- func (mr *MockMerkleDBMockRecorder) NewIteratorWithPrefix(arg0 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) NewIteratorWithStart(arg0 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) NewIteratorWithStartAndPrefix(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) NewPreallocatedView(arg0 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) NewView() *gomock.Call
- func (mr *MockMerkleDBMockRecorder) Put(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) Remove(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockMerkleDBMockRecorder) VerifyChangeProof(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
- type Proof
- type ProofGetter
- type ProofNode
- type RangeProof
- type RangeProofer
- type ReadOnlyTrie
- type SerializedPath
- func (s SerializedPath) AppendNibble(nibble byte) SerializedPath
- func (s SerializedPath) Equal(other SerializedPath) bool
- func (s SerializedPath) HasPrefix(prefix SerializedPath) bool
- func (s SerializedPath) HasStrictPrefix(prefix SerializedPath) bool
- func (s SerializedPath) NibbleVal(nibbleIndex int) byte
- type Trie
- type TrieView
Constants ¶
const ( DefaultEvictionBatchSize = 100 RootPath = EmptyPath )
const ( NodeBranchFactor = 16 HashLength = 32 )
const EmptyPath path = ""
Variables ¶
var ( ErrStartRootNotFound = errors.New("start root is not before end root in history") ErrRootIDNotPresent = errors.New("root id is not present in history") )
var ( ErrInvalidProof = errors.New("proof obtained an invalid root ID") ErrInvalidMaxLength = errors.New("expected max length to be > 0") ErrNonIncreasingValues = errors.New("keys sent are not in increasing order") ErrStateFromOutsideOfRange = errors.New("state key falls outside of the start->end range") ErrNonIncreasingProofNodes = errors.New("each proof node key must be a strict prefix of the next") ErrExtraProofNodes = errors.New("extra proof nodes in path") ErrDataInMissingRootProof = errors.New("there should be no state or deleted keys in a change proof that had a missing root") ErrNoMerkleProof = errors.New("empty key response must include merkle proof") ErrShouldJustBeRoot = errors.New("end proof should only contain root") ErrNoStartProof = errors.New("no start proof") ErrNoEndProof = errors.New("no end proof") ErrNoProof = errors.New("proof has no nodes") ErrProofNodeNotForKey = errors.New("the provided node has a key that is not a prefix of the specified key") ErrProofValueDoesntMatch = errors.New("the provided value does not match the proof node for the provided key's value") ErrProofNodeHasUnincludedValue = errors.New("the provided proof has a value for a key within the range that is not present in the provided key/values") ErrInvalidMaybe = errors.New("maybe is nothing but has value") ErrInvalidChildIndex = fmt.Errorf("child index must be less than %d", NodeBranchFactor) ErrNilProofNode = errors.New("proof node is nil") ErrNilValueOrHash = errors.New("proof node's valueOrHash field is nil") ErrNilSerializedPath = errors.New("serialized path is nil") ErrNilRangeProof = errors.New("range proof is nil") ErrNilChangeProof = errors.New("change proof is nil") ErrNilMaybeBytes = errors.New("maybe bytes is nil") ErrNilProof = errors.New("proof is nil") ErrNilValue = errors.New("value is nil") ErrUnexpectedEndProof = errors.New("end proof should be empty") )
var ( ErrCommitted = errors.New("view has been committed") ErrInvalid = errors.New("the trie this view was based on has changed, rendering this view invalid") ErrOddLengthWithValue = errors.New( "the underlying db only supports whole number of byte keys, so cannot record changes with odd nibble length", ) ErrGetPathToFailure = errors.New("GetPathTo failed to return the closest node") ErrStartAfterEnd = errors.New("start key > end key") ErrViewIsNotAChild = errors.New("passed in view is required to be a child of the current view") ErrNoValidRoot = errors.New("a valid root was not provided to the trieView constructor") )
Functions ¶
Types ¶
type ChangeProof ¶
type ChangeProof struct { // If false, the node that created this doesn't have // sufficient history to generate a change proof and // all other fields must be empty. // Otherwise at least one other field is non-empty. HadRootsInHistory bool // A proof that the smallest key in the requested range does/doesn't // exist in the trie with the requested start root. // Empty if no lower bound on the requested range was given. // Note that this may not be an entire proof -- nodes are omitted if // they are also in [EndProof]. StartProof []ProofNode // If [KeyChanges] is non-empty, this is a proof of the largest key // in [KeyChanges]. // // If [KeyChanges] is empty and an upper range bound was given, // this is a proof of the upper range bound. // // If [KeyChanges] is empty and no upper range bound was given, // this is empty. EndProof []ProofNode // A subset of key-values that were added, removed, or had their values // modified between the requested start root (exclusive) and the requested // end root (inclusive). // Each key is in the requested range (inclusive). // The first key-value is the first key-value at/after the range start. // The key-value pairs are consecutive. That is, if keys k1 and k2 are // in [KeyChanges] then there is no k3 that was modified between the start and // end roots such that k1 < k3 < k2. // This is a subset of the requested key-value range, rather than the entire // range, because otherwise the proof may be too large. // Sorted by increasing key and with no duplicate keys. // // Example: Suppose that between the start root and the end root, the following // key-value pairs were added, removed, or modified: // // [kv1, kv2, kv3, kv4, kv5] // where start <= kv1 < ... < kv5 <= end. // // The following are possible values of [KeyChanges]: // // [] // [kv1] // [kv1, kv2] // [kv1, kv2, kv3] // [kv1, kv2, kv3, kv4] // [kv1, kv2, kv3, kv4, kv5] // // The following values of [KeyChanges] are always invalid, for example: // // [kv2] (Doesn't include kv1, the first key-value at/after the range start) // [kv1, kv3] (Doesn't include kv2, the key-value between kv1 and kv3) // [kv1, kv3, kv2] (Not sorted by increasing key) // [kv1, kv1] (Duplicate key-value pairs) // [kv0, kv1] (For some kv1 < start) // [kv1, kv2, kv3, kv4, kv5, kv6] (For some kv6 > end) KeyChanges []KeyChange }
A change proof proves that a set of key-value changes occurred between two trie roots, where each key-value pair's key is between some lower and upper bound (inclusive).
func (*ChangeProof) Empty ¶
func (proof *ChangeProof) Empty() bool
func (*ChangeProof) ToProto ¶ added in v1.10.3
func (proof *ChangeProof) ToProto() *pb.ChangeProof
func (*ChangeProof) UnmarshalProto ¶ added in v1.10.3
func (proof *ChangeProof) UnmarshalProto(pbProof *pb.ChangeProof) error
type ChangeProofer ¶ added in v1.10.3
type ChangeProofer interface { // GetChangeProof returns a proof for a subset of the key/value changes in key range // [start, end] that occurred between [startRootID] and [endRootID]. // Returns at most [maxLength] key/value pairs. GetChangeProof( ctx context.Context, startRootID ids.ID, endRootID ids.ID, start []byte, end maybe.Maybe[[]byte], maxLength int, ) (*ChangeProof, error) // Returns nil iff all of the following hold: // - [start] <= [end]. // - [proof] is non-empty iff [proof.HadRootsInHistory]. // - All keys in [proof.KeyValues] and [proof.DeletedKeys] are in [start, end]. // If [start] is empty, all keys are considered > [start]. // If [end] is nothing, all keys are considered < [end]. // - [proof.KeyValues] and [proof.DeletedKeys] are sorted in order of increasing key. // - [proof.StartProof] and [proof.EndProof] are well-formed. // - When the keys in [proof.KeyValues] are added to [db] and the keys in [proof.DeletedKeys] // are removed from [db], the root ID of [db] is [expectedEndRootID]. // // Assumes [db.lock] isn't held. // This is defined on Database instead of ChangeProof because it accesses // database internals. VerifyChangeProof( ctx context.Context, proof *ChangeProof, start []byte, end maybe.Maybe[[]byte], expectedEndRootID ids.ID, ) error // CommitChangeProof commits the key/value pairs within the [proof] to the db. CommitChangeProof(ctx context.Context, proof *ChangeProof) error }
type Config ¶
type Config struct { // The number of nodes that are evicted from the cache and written to // disk at a time. EvictionBatchSize int // The number of changes to the database that we store in memory in order to // serve change proofs. HistoryLength int NodeCacheSize int // If [Reg] is nil, metrics are collected locally but not exported through // Prometheus. // This may be useful for testing. Reg prometheus.Registerer Tracer trace.Tracer }
type MerkleDB ¶ added in v1.10.2
type MerkleDB interface { database.Database Trie MerkleRootGetter ProofGetter ChangeProofer RangeProofer }
type MerkleRootGetter ¶ added in v1.10.3
type MockMerkleDB ¶ added in v1.10.2
type MockMerkleDB struct {
// contains filtered or unexported fields
}
MockMerkleDB is a mock of MerkleDB interface.
func NewMockMerkleDB ¶ added in v1.10.2
func NewMockMerkleDB(ctrl *gomock.Controller) *MockMerkleDB
NewMockMerkleDB creates a new mock instance.
func (*MockMerkleDB) Close ¶ added in v1.10.2
func (m *MockMerkleDB) Close() error
Close mocks base method.
func (*MockMerkleDB) CommitChangeProof ¶ added in v1.10.2
func (m *MockMerkleDB) CommitChangeProof(arg0 context.Context, arg1 *ChangeProof) error
CommitChangeProof mocks base method.
func (*MockMerkleDB) CommitRangeProof ¶ added in v1.10.2
func (m *MockMerkleDB) CommitRangeProof(arg0 context.Context, arg1 []byte, arg2 *RangeProof) error
CommitRangeProof mocks base method.
func (*MockMerkleDB) Compact ¶ added in v1.10.2
func (m *MockMerkleDB) Compact(arg0, arg1 []byte) error
Compact mocks base method.
func (*MockMerkleDB) Delete ¶ added in v1.10.2
func (m *MockMerkleDB) Delete(arg0 []byte) error
Delete mocks base method.
func (*MockMerkleDB) EXPECT ¶ added in v1.10.2
func (m *MockMerkleDB) EXPECT() *MockMerkleDBMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockMerkleDB) Get ¶ added in v1.10.2
func (m *MockMerkleDB) Get(arg0 []byte) ([]byte, error)
Get mocks base method.
func (*MockMerkleDB) GetChangeProof ¶ added in v1.10.2
func (m *MockMerkleDB) GetChangeProof(arg0 context.Context, arg1, arg2 ids.ID, arg3 []byte, arg4 maybe.Maybe[[]uint8], arg5 int) (*ChangeProof, error)
GetChangeProof mocks base method.
func (*MockMerkleDB) GetMerkleRoot ¶ added in v1.10.2
GetMerkleRoot mocks base method.
func (*MockMerkleDB) GetRangeProof ¶ added in v1.10.2
func (m *MockMerkleDB) GetRangeProof(arg0 context.Context, arg1 []byte, arg2 maybe.Maybe[[]uint8], arg3 int) (*RangeProof, error)
GetRangeProof mocks base method.
func (*MockMerkleDB) GetRangeProofAtRoot ¶ added in v1.10.2
func (m *MockMerkleDB) GetRangeProofAtRoot(arg0 context.Context, arg1 ids.ID, arg2 []byte, arg3 maybe.Maybe[[]uint8], arg4 int) (*RangeProof, error)
GetRangeProofAtRoot mocks base method.
func (*MockMerkleDB) Has ¶ added in v1.10.2
func (m *MockMerkleDB) Has(arg0 []byte) (bool, error)
Has mocks base method.
func (*MockMerkleDB) HealthCheck ¶ added in v1.10.2
func (m *MockMerkleDB) HealthCheck(arg0 context.Context) (interface{}, error)
HealthCheck mocks base method.
func (*MockMerkleDB) Insert ¶ added in v1.10.2
func (m *MockMerkleDB) Insert(arg0 context.Context, arg1, arg2 []byte) error
Insert mocks base method.
func (*MockMerkleDB) NewBatch ¶ added in v1.10.2
func (m *MockMerkleDB) NewBatch() database.Batch
NewBatch mocks base method.
func (*MockMerkleDB) NewIterator ¶ added in v1.10.2
func (m *MockMerkleDB) NewIterator() database.Iterator
NewIterator mocks base method.
func (*MockMerkleDB) NewIteratorWithPrefix ¶ added in v1.10.2
func (m *MockMerkleDB) NewIteratorWithPrefix(arg0 []byte) database.Iterator
NewIteratorWithPrefix mocks base method.
func (*MockMerkleDB) NewIteratorWithStart ¶ added in v1.10.2
func (m *MockMerkleDB) NewIteratorWithStart(arg0 []byte) database.Iterator
NewIteratorWithStart mocks base method.
func (*MockMerkleDB) NewIteratorWithStartAndPrefix ¶ added in v1.10.2
func (m *MockMerkleDB) NewIteratorWithStartAndPrefix(arg0, arg1 []byte) database.Iterator
NewIteratorWithStartAndPrefix mocks base method.
func (*MockMerkleDB) NewPreallocatedView ¶ added in v1.10.2
func (m *MockMerkleDB) NewPreallocatedView(arg0 int) (TrieView, error)
NewPreallocatedView mocks base method.
func (*MockMerkleDB) NewView ¶ added in v1.10.2
func (m *MockMerkleDB) NewView() (TrieView, error)
NewView mocks base method.
func (*MockMerkleDB) Put ¶ added in v1.10.2
func (m *MockMerkleDB) Put(arg0, arg1 []byte) error
Put mocks base method.
func (*MockMerkleDB) Remove ¶ added in v1.10.2
func (m *MockMerkleDB) Remove(arg0 context.Context, arg1 []byte) error
Remove mocks base method.
func (*MockMerkleDB) VerifyChangeProof ¶ added in v1.10.2
func (m *MockMerkleDB) VerifyChangeProof(arg0 context.Context, arg1 *ChangeProof, arg2 []byte, arg3 maybe.Maybe[[]uint8], arg4 ids.ID) error
VerifyChangeProof mocks base method.
type MockMerkleDBMockRecorder ¶ added in v1.10.2
type MockMerkleDBMockRecorder struct {
// contains filtered or unexported fields
}
MockMerkleDBMockRecorder is the mock recorder for MockMerkleDB.
func (*MockMerkleDBMockRecorder) Close ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockMerkleDBMockRecorder) CommitChangeProof ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) CommitChangeProof(arg0, arg1 interface{}) *gomock.Call
CommitChangeProof indicates an expected call of CommitChangeProof.
func (*MockMerkleDBMockRecorder) CommitRangeProof ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) CommitRangeProof(arg0, arg1, arg2 interface{}) *gomock.Call
CommitRangeProof indicates an expected call of CommitRangeProof.
func (*MockMerkleDBMockRecorder) Compact ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) Compact(arg0, arg1 interface{}) *gomock.Call
Compact indicates an expected call of Compact.
func (*MockMerkleDBMockRecorder) Delete ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) Delete(arg0 interface{}) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockMerkleDBMockRecorder) Get ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) Get(arg0 interface{}) *gomock.Call
Get indicates an expected call of Get.
func (*MockMerkleDBMockRecorder) GetChangeProof ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) GetChangeProof(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call
GetChangeProof indicates an expected call of GetChangeProof.
func (*MockMerkleDBMockRecorder) GetMerkleRoot ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) GetMerkleRoot(arg0 interface{}) *gomock.Call
GetMerkleRoot indicates an expected call of GetMerkleRoot.
func (*MockMerkleDBMockRecorder) GetProof ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) GetProof(arg0, arg1 interface{}) *gomock.Call
GetProof indicates an expected call of GetProof.
func (*MockMerkleDBMockRecorder) GetRangeProof ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) GetRangeProof(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
GetRangeProof indicates an expected call of GetRangeProof.
func (*MockMerkleDBMockRecorder) GetRangeProofAtRoot ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) GetRangeProofAtRoot(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
GetRangeProofAtRoot indicates an expected call of GetRangeProofAtRoot.
func (*MockMerkleDBMockRecorder) GetValue ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) GetValue(arg0, arg1 interface{}) *gomock.Call
GetValue indicates an expected call of GetValue.
func (*MockMerkleDBMockRecorder) GetValues ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) GetValues(arg0, arg1 interface{}) *gomock.Call
GetValues indicates an expected call of GetValues.
func (*MockMerkleDBMockRecorder) Has ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) Has(arg0 interface{}) *gomock.Call
Has indicates an expected call of Has.
func (*MockMerkleDBMockRecorder) HealthCheck ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) HealthCheck(arg0 interface{}) *gomock.Call
HealthCheck indicates an expected call of HealthCheck.
func (*MockMerkleDBMockRecorder) Insert ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) Insert(arg0, arg1, arg2 interface{}) *gomock.Call
Insert indicates an expected call of Insert.
func (*MockMerkleDBMockRecorder) NewBatch ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) NewBatch() *gomock.Call
NewBatch indicates an expected call of NewBatch.
func (*MockMerkleDBMockRecorder) NewIterator ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) NewIterator() *gomock.Call
NewIterator indicates an expected call of NewIterator.
func (*MockMerkleDBMockRecorder) NewIteratorWithPrefix ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) NewIteratorWithPrefix(arg0 interface{}) *gomock.Call
NewIteratorWithPrefix indicates an expected call of NewIteratorWithPrefix.
func (*MockMerkleDBMockRecorder) NewIteratorWithStart ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) NewIteratorWithStart(arg0 interface{}) *gomock.Call
NewIteratorWithStart indicates an expected call of NewIteratorWithStart.
func (*MockMerkleDBMockRecorder) NewIteratorWithStartAndPrefix ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) NewIteratorWithStartAndPrefix(arg0, arg1 interface{}) *gomock.Call
NewIteratorWithStartAndPrefix indicates an expected call of NewIteratorWithStartAndPrefix.
func (*MockMerkleDBMockRecorder) NewPreallocatedView ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) NewPreallocatedView(arg0 interface{}) *gomock.Call
NewPreallocatedView indicates an expected call of NewPreallocatedView.
func (*MockMerkleDBMockRecorder) NewView ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) NewView() *gomock.Call
NewView indicates an expected call of NewView.
func (*MockMerkleDBMockRecorder) Put ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) Put(arg0, arg1 interface{}) *gomock.Call
Put indicates an expected call of Put.
func (*MockMerkleDBMockRecorder) Remove ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) Remove(arg0, arg1 interface{}) *gomock.Call
Remove indicates an expected call of Remove.
func (*MockMerkleDBMockRecorder) VerifyChangeProof ¶ added in v1.10.2
func (mr *MockMerkleDBMockRecorder) VerifyChangeProof(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
VerifyChangeProof indicates an expected call of VerifyChangeProof.
type Proof ¶
type Proof struct { // Nodes in the proof path from root --> target key // (or node that would be where key is if it doesn't exist). // Must always be non-empty (i.e. have the root node). Path []ProofNode // This is a proof that [key] exists/doesn't exist. Key []byte // Nothing if [Key] isn't in the trie. // Otherwise the value corresponding to [Key]. Value maybe.Maybe[[]byte] }
An inclusion/exclustion proof of a key.
func (*Proof) UnmarshalProto ¶ added in v1.10.3
type ProofGetter ¶ added in v1.10.3
type ProofNode ¶
type ProofNode struct { KeyPath SerializedPath // Nothing if this is an intermediate node. // The value in this node if its length < [HashLen]. // The hash of the value in this node otherwise. ValueOrHash maybe.Maybe[[]byte] Children map[byte]ids.ID }
type RangeProof ¶
type RangeProof struct { // A proof that the smallest key in the requested range does/doesn't exist. // Note that this may not be an entire proof -- nodes are omitted if // they are also in [EndProof]. StartProof []ProofNode // If no upper range bound was given, [KeyValues] is empty, // and [StartProof] is non-empty, this is empty. // // If no upper range bound was given, [KeyValues] is empty, // and [StartProof] is empty, this is the root. // // If an upper range bound was given and [KeyValues] is empty, // this is a proof for the upper range bound. // // Otherwise, this is a proof for the largest key in [KeyValues]. EndProof []ProofNode // This proof proves that the key-value pairs in [KeyValues] are in the trie. // Sorted by increasing key. KeyValues []KeyValue }
A proof that a given set of key-value pairs are in a trie.
func (*RangeProof) ToProto ¶ added in v1.10.3
func (proof *RangeProof) ToProto() *pb.RangeProof
func (*RangeProof) UnmarshalProto ¶ added in v1.10.3
func (proof *RangeProof) UnmarshalProto(pbProof *pb.RangeProof) error
func (*RangeProof) Verify ¶
func (proof *RangeProof) Verify( ctx context.Context, start []byte, end maybe.Maybe[[]byte], expectedRootID ids.ID, ) error
Returns nil iff all the following hold:
- The invariants of RangeProof hold.
- [start] <= [end].
- [proof] proves the key-value pairs in [proof.KeyValues] are in the trie whose root is [expectedRootID].
- All keys in [proof.KeyValues] are in the range [start, end]. If [start] is empty, all keys are considered > [start]. If [end] is empty, all keys are considered < [end].
type RangeProofer ¶ added in v1.10.3
type RangeProofer interface { // GetRangeProofAtRoot returns a proof for the key/value pairs in this trie within the range // [start, end] when the root of the trie was [rootID]. GetRangeProofAtRoot( ctx context.Context, rootID ids.ID, start []byte, end maybe.Maybe[[]byte], maxLength int, ) (*RangeProof, error) // CommitRangeProof commits the key/value pairs within the [proof] to the db. // [start] is the smallest key in the range this [proof] covers. CommitRangeProof(ctx context.Context, start []byte, proof *RangeProof) error }
type ReadOnlyTrie ¶
type ReadOnlyTrie interface { MerkleRootGetter ProofGetter // GetValue gets the value associated with the specified key // database.ErrNotFound if the key is not present GetValue(ctx context.Context, key []byte) ([]byte, error) // GetValues gets the values associated with the specified keys // database.ErrNotFound if the key is not present GetValues(ctx context.Context, keys [][]byte) ([][]byte, []error) // GetRangeProof generates a proof of up to maxLength smallest key/values with keys between start and end GetRangeProof(ctx context.Context, start []byte, end maybe.Maybe[[]byte], maxLength int) (*RangeProof, error) database.Iteratee // contains filtered or unexported methods }
type SerializedPath ¶
SerializedPath contains a path from the trie. The trie branch factor is 16, so the path may contain an odd number of nibbles. If it did contain an odd number of nibbles, the last 4 bits of the last byte should be discarded.
func (SerializedPath) AppendNibble ¶
func (s SerializedPath) AppendNibble(nibble byte) SerializedPath
func (SerializedPath) Equal ¶
func (s SerializedPath) Equal(other SerializedPath) bool
func (SerializedPath) HasPrefix ¶
func (s SerializedPath) HasPrefix(prefix SerializedPath) bool
HasPrefix returns true iff [prefix] is a prefix of [s] or equal to it.
func (SerializedPath) HasStrictPrefix ¶
func (s SerializedPath) HasStrictPrefix(prefix SerializedPath) bool
Returns true iff [prefix] is a prefix of [s] but not equal to it.
func (SerializedPath) NibbleVal ¶
func (s SerializedPath) NibbleVal(nibbleIndex int) byte
type Trie ¶
type Trie interface { ReadOnlyTrie // Remove will delete a key from the Trie Remove(ctx context.Context, key []byte) error // NewPreallocatedView returns a new view on top of this Trie with space allocated for changes NewPreallocatedView(estimatedChanges int) (TrieView, error) // NewView returns a new view on top of this Trie NewView() (TrieView, error) // Insert a key/value pair into the Trie Insert(ctx context.Context, key, value []byte) error }
type TrieView ¶
type TrieView interface { Trie // CommitToDB takes the changes of this trie and commits them down the view stack // until all changes in the stack commit to the database // Takes the DB commit lock CommitToDB(ctx context.Context) error // CommitToParent takes changes of this TrieView and commits them to its parent Trie // Takes the DB commit lock CommitToParent(ctx context.Context) error // contains filtered or unexported methods }