core, ethdb, tests, trie: introduce database snapshot (#24486)

This commit is contained in:
rjl493456442
2022-03-10 16:35:22 +08:00
committed by GitHub
parent 5079e3c6e5
commit 8c8a9e5ca1
9 changed files with 223 additions and 2 deletions

View File

@ -177,6 +177,13 @@ func (t *table) NewBatchWithSize(size int) ethdb.Batch {
return &tableBatch{t.db.NewBatchWithSize(size), t.prefix}
}
// NewSnapshot creates a database snapshot based on the current state.
// The created snapshot will not be affected by all following mutations
// happened on the database.
func (t *table) NewSnapshot() (ethdb.Snapshot, error) {
return t.db.NewSnapshot()
}
// tableBatch is a wrapper around a database batch that prefixes each key access
// with a pre-configured string.
type tableBatch struct {