-
Notifications
You must be signed in to change notification settings - Fork 710
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
merkledb
-- nits
#1916
merkledb
-- nits
#1916
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,12 @@ import "github.com/ava-labs/avalanchego/database" | |
|
||
var _ database.Batch = (*batch)(nil) | ||
|
||
// batch is a write-only database that commits changes to its host database | ||
// when Write is called. | ||
type batch struct { | ||
database.BatchOps | ||
|
||
db *merkleDB | ||
} | ||
|
||
// apply all operations in order to the database and write the result to disk | ||
func (b *batch) Write() error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is documented on |
||
return b.db.commitBatch(b.Ops) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,11 +76,8 @@ type ChangeProofer interface { | |
// 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]. | ||
// | ||
// This is defined on Database instead of ChangeProof because it accesses | ||
// database internals. | ||
// - When the changes in [proof.KeyChanes] are applied, | ||
// the root ID of the database is [expectedEndRootID]. | ||
Comment on lines
+79
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
VerifyChangeProof( | ||
ctx context.Context, | ||
proof *ChangeProof, | ||
|
@@ -146,6 +143,7 @@ type merkleDB struct { | |
// Should be held before taking [db.lock] | ||
commitLock sync.RWMutex | ||
|
||
// Stores this trie's nodes. | ||
nodeDB database.Database | ||
|
||
// Stores data about the database's current state. | ||
|
@@ -155,7 +153,8 @@ type merkleDB struct { | |
// Note that a call to Put may cause a node to be evicted | ||
// from the cache, which will call [OnEviction]. | ||
// A non-nil error returned from Put is considered fatal. | ||
nodeCache onEvictCache[path, *node] | ||
nodeCache onEvictCache[path, *node] | ||
// Stores any error returned by [onEviction]. | ||
onEvictionErr utils.Atomic[error] | ||
evictionBatchSize int | ||
|
||
|
@@ -979,6 +978,8 @@ func (*merkleDB) CommitToDB(context.Context) error { | |
return nil | ||
} | ||
|
||
// This is defined on merkleDB instead of ChangeProof | ||
// because it accesses database internals. | ||
Comment on lines
+981
to
+982
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved from |
||
// Assumes [db.lock] isn't held. | ||
func (db *merkleDB) VerifyChangeProof( | ||
ctx context.Context, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is documented on
database.Batch
so no need to do it here