43
43
44
44
Codec , Version = newCodec ()
45
45
46
- rootKey = []byte {}
46
+ rootKey []byte
47
47
nodePrefix = []byte ("node" )
48
48
metadataPrefix = []byte ("metadata" )
49
49
cleanShutdownKey = []byte ("cleanShutdown" )
@@ -65,7 +65,7 @@ type Config struct {
65
65
Tracer trace.Tracer
66
66
}
67
67
68
- // Can only be edited by committing changes from a trieView.
68
+ // Database can only be edited by committing changes from a trieView.
69
69
type Database struct {
70
70
// Must be held when reading/writing fields.
71
71
lock sync.RWMutex
@@ -225,7 +225,7 @@ func New(ctx context.Context, db database.Database, config Config) (*Database, e
225
225
return newDatabase (ctx , db , config , metrics )
226
226
}
227
227
228
- // Commits the key/value pairs within the [proof] to the db.
228
+ // CommitChangeProof commits the key/value pairs within the [proof] to the db.
229
229
func (db * Database ) CommitChangeProof (ctx context.Context , proof * ChangeProof ) error {
230
230
db .commitLock .Lock ()
231
231
defer db .commitLock .Unlock ()
@@ -241,7 +241,7 @@ func (db *Database) CommitChangeProof(ctx context.Context, proof *ChangeProof) e
241
241
return view .commitToDB (ctx )
242
242
}
243
243
244
- // Commits the key/value pairs within the [proof] to the db.
244
+ // CommitRangeProof commits the key/value pairs within the [proof] to the db.
245
245
// [start] is the smallest key in the range this [proof] covers.
246
246
func (db * Database ) CommitRangeProof (ctx context.Context , start []byte , proof * RangeProof ) error {
247
247
db .commitLock .Lock ()
@@ -354,7 +354,7 @@ func (db *Database) getValueCopy(key path, lock bool) ([]byte, error) {
354
354
// getValue returns the value for the given [key].
355
355
// Returns database.ErrNotFound if it doesn't exist.
356
356
// If [lock], [db.lock]'s read lock is acquired.
357
- // Otherwise assumes [db.lock] is already held.
357
+ // Otherwise, assumes [db.lock] is already held.
358
358
func (db * Database ) getValue (key path , lock bool ) ([]byte , error ) {
359
359
if lock {
360
360
db .lock .RLock ()
@@ -375,7 +375,7 @@ func (db *Database) getValue(key path, lock bool) ([]byte, error) {
375
375
return n .value .value , nil
376
376
}
377
377
378
- // Returns the ID of the root node of the merkle trie.
378
+ // GetMerkleRoot returns the ID of the root node of the merkle trie.
379
379
func (db * Database ) GetMerkleRoot (ctx context.Context ) (ids.ID , error ) {
380
380
_ , span := db .tracer .Start (ctx , "MerkleDB.GetMerkleRoot" )
381
381
defer span .End ()
@@ -396,7 +396,7 @@ func (db *Database) getMerkleRoot() ids.ID {
396
396
return db .root .id
397
397
}
398
398
399
- // Returns a proof of the existence/non-existence of [key] in this trie.
399
+ // GetProof returns a proof of the existence/non-existence of [key] in this trie.
400
400
func (db * Database ) GetProof (ctx context.Context , key []byte ) (* Proof , error ) {
401
401
db .commitLock .RLock ()
402
402
defer db .commitLock .RUnlock ()
@@ -419,7 +419,7 @@ func (db *Database) getProof(ctx context.Context, key []byte) (*Proof, error) {
419
419
return view .getProof (ctx , key )
420
420
}
421
421
422
- // Returns a proof for the key/value pairs in this trie within the range
422
+ // GetRangeProof returns a proof for the key/value pairs in this trie within the range
423
423
// [start, end].
424
424
func (db * Database ) GetRangeProof (
425
425
ctx context.Context ,
@@ -433,7 +433,7 @@ func (db *Database) GetRangeProof(
433
433
return db .getRangeProofAtRoot (ctx , db .getMerkleRoot (), start , end , maxLength )
434
434
}
435
435
436
- // Returns a proof for the key/value pairs in this trie within the range
436
+ // GetRangeProofAtRoot returns a proof for the key/value pairs in this trie within the range
437
437
// [start, end] when the root of the trie was [rootID].
438
438
func (db * Database ) GetRangeProofAtRoot (
439
439
ctx context.Context ,
@@ -470,7 +470,7 @@ func (db *Database) getRangeProofAtRoot(
470
470
return historicalView .GetRangeProof (ctx , start , end , maxLength )
471
471
}
472
472
473
- // Returns a proof for a subset of the key/value changes in key range
473
+ // GetChangeProof returns a proof for a subset of the key/value changes in key range
474
474
// [start, end] that occurred between [startRootID] and [endRootID].
475
475
// Returns at most [maxLength] key/value pairs.
476
476
func (db * Database ) GetChangeProof (
@@ -577,7 +577,7 @@ func (db *Database) GetChangeProof(
577
577
return result , nil
578
578
}
579
579
580
- // Returns a new view on top of this trie.
580
+ // NewView returns a new view on top of this trie.
581
581
// Changes made to the view will only be reflected in the original trie if Commit is called.
582
582
// Assumes [db.lock] isn't held.
583
583
func (db * Database ) NewView () (TrieView , error ) {
@@ -591,7 +591,7 @@ func (db *Database) newUntrackedView(estimatedSize int) (*trieView, error) {
591
591
return newTrieView (db , db , db .root .clone (), estimatedSize )
592
592
}
593
593
594
- // Returns a new view preallocated to hold at least [estimatedSize] value changes at a time.
594
+ // NewPreallocatedView returns a new view with memory allocated to hold at least [estimatedSize] value changes at a time.
595
595
// If more changes are made, additional memory will be allocated.
596
596
// The returned view is added to [db.childViews].
597
597
// Assumes [db.lock] isn't held.
@@ -721,7 +721,7 @@ func (db *Database) onEviction(node *node) error {
721
721
return nil
722
722
}
723
723
724
- // Inserts the key/value pair into the db.
724
+ // Put upserts the key/value pair into the db.
725
725
func (db * Database ) Put (k , v []byte ) error {
726
726
return db .Insert (context .Background (), k , v )
727
727
}
0 commit comments