Versions in this module Expand all Collapse all v1 v1.11.3-rc.1 Oct 29, 2024 v1.11.3-rc.0 Oct 29, 2024 v1.10.8 Oct 29, 2024 v1.7.17-rc.2 Nov 5, 2024 v1.0.0 Nov 7, 2024 Changes in this version + const BranchFactor16 + const BranchFactor2 + const BranchFactor256 + const BranchFactor4 + const HashLength + var BranchFactorToTokenSize = map[BranchFactor]int + var ErrCommitted = errors.New("view has been committed") + var ErrDataInMissingRootProof = errors.New(...) + var ErrEmptyProof = errors.New("proof is empty") + var ErrExtraProofNodes = errors.New("extra proof nodes in path") + var ErrInsufficientHistory = errors.New("insufficient history to generate proof") + var ErrInvalid = errors.New("the trie this view was based on has changed, rendering this view invalid") + var ErrInvalidBranchFactor = errors.New("branch factor must match one of the predefined branch factors") + var ErrInvalidKeyLength = errors.New("key length doesn't match bytes length, check specified branchFactor") + var ErrInvalidMaxLength = errors.New("expected max length to be > 0") + var ErrInvalidMaybe = errors.New("maybe is nothing but has value") + var ErrInvalidProof = errors.New("proof obtained an invalid root ID") + var ErrNilChangeProof = errors.New("change proof is nil") + var ErrNilKey = errors.New("key is nil") + var ErrNilMaybeBytes = errors.New("maybe bytes is nil") + var ErrNilProof = errors.New("proof is nil") + var ErrNilProofNode = errors.New("proof node is nil") + var ErrNilRangeProof = errors.New("range proof is nil") + var ErrNilValue = errors.New("value is nil") + var ErrNilValueOrHash = errors.New("proof node's valueOrHash field is nil") + var ErrNoChanges = errors.New("no changes provided") + var ErrNoEndProof = errors.New("no end proof") + var ErrNoEndRoot = fmt.Errorf("%w: end root not found", ErrInsufficientHistory) + var ErrNoMerkleProof = errors.New("empty key response must include merkle proof") + var ErrNoStartProof = errors.New("no start proof") + var ErrNodesAlreadyCalculated = errors.New("cannot modify the trie after the node changes have been calculated") + var ErrNonIncreasingProofNodes = errors.New("each proof node key must be a strict prefix of the next") + var ErrNonIncreasingValues = errors.New("keys sent are not in increasing order") + var ErrParentNotDatabase = errors.New("parent trie is not database") + var ErrPartialByteLengthWithValue = errors.New(...) + var ErrProofNodeHasUnincludedValue = errors.New(...) + var ErrProofNodeNotForKey = errors.New("the provided node has a key that is not a prefix of the specified key") + var ErrProofValueDoesntMatch = errors.New(...) + var ErrShouldJustBeRoot = errors.New("end proof should only contain root") + var ErrStartAfterEnd = errors.New("start key > end key") + var ErrStateFromOutsideOfRange = errors.New("state key falls outside of the start->end range") + var ErrUnexpectedEndProof = errors.New("end proof should be empty") + var ErrVisitPathToKey = errors.New("failed to visit expected node during insertion") + type BranchFactor int + func (b BranchFactor) Valid() error + type ChangeOrRangeProof struct + ChangeProof *ChangeProof + RangeProof *RangeProof + type ChangeProof struct + EndProof []ProofNode + KeyChanges []KeyChange + StartProof []ProofNode + func (proof *ChangeProof) Empty() bool + func (proof *ChangeProof) ToProto() *pb.ChangeProof + func (proof *ChangeProof) UnmarshalProto(pbProof *pb.ChangeProof) error + type ChangeProofer interface + CommitChangeProof func(ctx context.Context, proof *ChangeProof) error + GetChangeProof func(ctx context.Context, startRootID ids.ID, endRootID ids.ID, ...) (*ChangeProof, error) + VerifyChangeProof func(ctx context.Context, proof *ChangeProof, start maybe.Maybe[[]byte], ...) error + type Clearer interface + Clear func() error + type Config struct + BranchFactor BranchFactor + HistoryLength uint + IntermediateNodeCacheSize uint + IntermediateWriteBatchSize uint + IntermediateWriteBufferSize uint + Reg prometheus.Registerer + RootGenConcurrency uint + TraceLevel TraceLevel + Tracer trace.Tracer + ValueNodeCacheSize uint + type Key struct + func ToKey(keyBytes []byte) Key + func ToToken(val byte, tokenSize int) Key + func (k Key) Bytes() []byte + func (k Key) Compare(other Key) int + func (k Key) Extend(keys ...Key) Key + func (k Key) Greater(other Key) bool + func (k Key) HasPrefix(prefix Key) bool + func (k Key) HasStrictPrefix(prefix Key) bool + func (k Key) Length() int + func (k Key) Less(other Key) bool + func (k Key) Skip(bitsToSkip int) Key + func (k Key) Take(bitsToTake int) Key + func (k Key) Token(bitIndex int, tokenSize int) byte + type KeyChange struct + Key []byte + Value maybe.Maybe[[]byte] + type KeyValue struct + Key []byte + Value []byte + type MerkleDB interface + func New(ctx context.Context, db database.Database, config Config) (MerkleDB, error) + type MerkleRootGetter interface + GetMerkleRoot func(ctx context.Context) (ids.ID, error) + type MockMerkleDB struct + func NewMockMerkleDB(ctrl *gomock.Controller) *MockMerkleDB + func (m *MockMerkleDB) Clear() error + func (m *MockMerkleDB) Close() error + func (m *MockMerkleDB) CommitChangeProof(ctx context.Context, proof *ChangeProof) error + func (m *MockMerkleDB) CommitRangeProof(ctx context.Context, start, end maybe.Maybe[[]byte], proof *RangeProof) error + func (m *MockMerkleDB) Compact(start, limit []byte) error + func (m *MockMerkleDB) Delete(key []byte) error + func (m *MockMerkleDB) EXPECT() *MockMerkleDBMockRecorder + func (m *MockMerkleDB) Get(key []byte) ([]byte, error) + func (m *MockMerkleDB) GetChangeProof(ctx context.Context, startRootID, endRootID ids.ID, ...) (*ChangeProof, error) + func (m *MockMerkleDB) GetMerkleRoot(ctx context.Context) (ids.ID, error) + func (m *MockMerkleDB) GetProof(ctx context.Context, keyBytes []byte) (*Proof, error) + func (m *MockMerkleDB) GetRangeProof(ctx context.Context, start, end maybe.Maybe[[]byte], maxLength int) (*RangeProof, error) + func (m *MockMerkleDB) GetRangeProofAtRoot(ctx context.Context, rootID ids.ID, start, end maybe.Maybe[[]byte], ...) (*RangeProof, error) + func (m *MockMerkleDB) GetValue(ctx context.Context, key []byte) ([]byte, error) + func (m *MockMerkleDB) GetValues(ctx context.Context, keys [][]byte) ([][]byte, []error) + func (m *MockMerkleDB) Has(key []byte) (bool, error) + func (m *MockMerkleDB) HealthCheck(arg0 context.Context) (any, error) + func (m *MockMerkleDB) NewBatch() database.Batch + func (m *MockMerkleDB) NewIterator() database.Iterator + func (m *MockMerkleDB) NewIteratorWithPrefix(prefix []byte) database.Iterator + func (m *MockMerkleDB) NewIteratorWithStart(start []byte) database.Iterator + func (m *MockMerkleDB) NewIteratorWithStartAndPrefix(start, prefix []byte) database.Iterator + func (m *MockMerkleDB) NewView(ctx context.Context, changes ViewChanges) (View, error) + func (m *MockMerkleDB) PrefetchPath(key []byte) error + func (m *MockMerkleDB) PrefetchPaths(keys [][]byte) error + func (m *MockMerkleDB) Put(key, value []byte) error + func (m *MockMerkleDB) VerifyChangeProof(ctx context.Context, proof *ChangeProof, start, end maybe.Maybe[[]byte], ...) error + type MockMerkleDBMockRecorder struct + func (mr *MockMerkleDBMockRecorder) Clear() *gomock.Call + func (mr *MockMerkleDBMockRecorder) Close() *gomock.Call + func (mr *MockMerkleDBMockRecorder) CommitChangeProof(ctx, proof any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) CommitRangeProof(ctx, start, end, proof any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) Compact(start, limit any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) Delete(key any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) Get(key any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) GetChangeProof(ctx, startRootID, endRootID, start, end, maxLength any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) GetMerkleRoot(ctx any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) GetProof(ctx, keyBytes any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) GetRangeProof(ctx, start, end, maxLength any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) GetRangeProofAtRoot(ctx, rootID, start, end, maxLength any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) GetValue(ctx, key any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) GetValues(ctx, keys any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) Has(key any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) HealthCheck(arg0 any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) NewBatch() *gomock.Call + func (mr *MockMerkleDBMockRecorder) NewIterator() *gomock.Call + func (mr *MockMerkleDBMockRecorder) NewIteratorWithPrefix(prefix any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) NewIteratorWithStart(start any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) NewIteratorWithStartAndPrefix(start, prefix any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) NewView(ctx, changes any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) PrefetchPath(key any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) PrefetchPaths(keys any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) Put(key, value any) *gomock.Call + func (mr *MockMerkleDBMockRecorder) VerifyChangeProof(ctx, proof, start, end, expectedEndRootID any) *gomock.Call + type Prefetcher interface + PrefetchPath func(key []byte) error + PrefetchPaths func(keys [][]byte) error + type Proof struct + Key Key + Path []ProofNode + Value maybe.Maybe[[]byte] + func (proof *Proof) ToProto() *pb.Proof + func (proof *Proof) UnmarshalProto(pbProof *pb.Proof) error + func (proof *Proof) Verify(ctx context.Context, expectedRootID ids.ID, tokenSize int) error + type ProofGetter interface + GetProof func(ctx context.Context, keyBytes []byte) (*Proof, error) + type ProofNode struct + Children map[byte]ids.ID + Key Key + ValueOrHash maybe.Maybe[[]byte] + func (node *ProofNode) ToProto() *pb.ProofNode + func (node *ProofNode) UnmarshalProto(pbNode *pb.ProofNode) error + type RangeProof struct + EndProof []ProofNode + KeyValues []KeyValue + StartProof []ProofNode + func (proof *RangeProof) ToProto() *pb.RangeProof + func (proof *RangeProof) UnmarshalProto(pbProof *pb.RangeProof) error + func (proof *RangeProof) Verify(ctx context.Context, start maybe.Maybe[[]byte], end maybe.Maybe[[]byte], ...) error + type RangeProofer interface + CommitRangeProof func(ctx context.Context, start, end maybe.Maybe[[]byte], proof *RangeProof) error + GetRangeProofAtRoot func(ctx context.Context, rootID ids.ID, start maybe.Maybe[[]byte], ...) (*RangeProof, error) + type TraceLevel int + const DebugTrace + const InfoTrace + const NoTrace + type Trie interface + GetRangeProof func(ctx context.Context, start maybe.Maybe[[]byte], end maybe.Maybe[[]byte], ...) (*RangeProof, error) + GetValue func(ctx context.Context, key []byte) ([]byte, error) + GetValues func(ctx context.Context, keys [][]byte) ([][]byte, []error) + NewView func(ctx context.Context, changes ViewChanges) (View, error) + type View interface + CommitToDB func(ctx context.Context) error + type ViewChanges struct + BatchOps []database.BatchOp + ConsumeBytes bool + MapOps map[string]maybe.Maybe[[]byte] v0 v0.13.8-rc.1 Nov 6, 2024