@@ -493,16 +493,17 @@ func (db *Database) removeProposalFromMap(pCtx *ProposalContext) {
493493// Reader retrieves a node reader belonging to the given state root.
494494// An error will be returned if the requested state is not available.
495495func (db * Database ) Reader (root common.Hash ) (database.Reader , error ) {
496- if _ , err := db .fwDisk .GetFromRoot (ffi .Hash (root ), []byte {}); err != nil {
496+ revision , err := db .fwDisk .Revision (ffi .Hash (root ))
497+ if err != nil {
497498 return nil , fmt .Errorf ("firewood: unable to retrieve from root %s: %w" , root .Hex (), err )
498499 }
499- return & reader {db : db , root : ffi .Hash (root )}, nil
500+ fmt .Printf ("Firewood Reader created at %p\n " , revision )
501+ return & reader {revision : revision }, nil
500502}
501503
502504// reader is a state reader of Database which implements the Reader interface.
503505type reader struct {
504- db * Database
505- root ffi.Hash // The root of the state this reader is reading.
506+ revision * ffi.Revision
506507}
507508
508509// Node retrieves the trie node with the given node hash. No error will be
@@ -511,7 +512,7 @@ func (reader *reader) Node(_ common.Hash, path []byte, _ common.Hash) ([]byte, e
511512 // This function relies on Firewood's internal locking to ensure concurrent reads are safe.
512513 // This is safe even if a proposal is being committed concurrently.
513514 start := time .Now ()
514- result , err := reader .db . fwDisk . GetFromRoot ( reader . root , path )
515+ result , err := reader .revision . Get ( path )
515516 if metrics .EnabledExpensive {
516517 ffiReadCount .Inc (1 )
517518 ffiReadTimer .Inc (time .Since (start ).Milliseconds ())
0 commit comments