@@ -482,16 +482,17 @@ func (db *Database) removeProposalFromMap(pCtx *ProposalContext) {
482482// Reader retrieves a node reader belonging to the given state root.
483483// An error will be returned if the requested state is not available.
484484func (db * Database ) Reader (root common.Hash ) (database.Reader , error ) {
485- if _ , err := db .fwDisk .GetFromRoot (root .Bytes (), []byte {}); err != nil {
485+ revision , err := db .fwDisk .Revision (root .Bytes ())
486+ if err != nil {
486487 return nil , fmt .Errorf ("firewood: unable to retrieve from root %s: %w" , root .Hex (), err )
487488 }
488- return & reader {db : db , root : root }, nil
489+ fmt .Printf ("Firewood Reader created at %p\n " , revision )
490+ return & reader {revision : revision }, nil
489491}
490492
491493// reader is a state reader of Database which implements the Reader interface.
492494type reader struct {
493- db * Database
494- root common.Hash // The root of the state this reader is reading.
495+ revision * ffi.Revision
495496}
496497
497498// Node retrieves the trie node with the given node hash. No error will be
@@ -500,7 +501,7 @@ func (reader *reader) Node(_ common.Hash, path []byte, _ common.Hash) ([]byte, e
500501 // This function relies on Firewood's internal locking to ensure concurrent reads are safe.
501502 // This is safe even if a proposal is being committed concurrently.
502503 start := time .Now ()
503- result , err := reader .db . fwDisk . GetFromRoot ( reader . root . Bytes (), path )
504+ result , err := reader .revision . Get ( path )
504505 if metrics .EnabledExpensive {
505506 ffiReadCount .Inc (1 )
506507 ffiReadTimer .Inc (time .Since (start ).Milliseconds ())
0 commit comments