Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ func (pool *LegacyPool) Close() error {
if pool.journal != nil {
pool.journal.close()
}

// remove all references to state to allow GC to reclaim memory
pool.pendingNonces = nil
pool.currentState = nil

log.Info("Transaction pool stopped")
return nil
}
Expand Down
11 changes: 6 additions & 5 deletions triedb/firewood/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,17 @@ func (db *Database) removeProposalFromMap(pCtx *ProposalContext) {
// Reader retrieves a node reader belonging to the given state root.
// An error will be returned if the requested state is not available.
func (db *Database) Reader(root common.Hash) (database.Reader, error) {
if _, err := db.fwDisk.GetFromRoot(ffi.Hash(root), []byte{}); err != nil {
revision, err := db.fwDisk.Revision(ffi.Hash(root))
if err != nil {
return nil, fmt.Errorf("firewood: unable to retrieve from root %s: %w", root.Hex(), err)
}
return &reader{db: db, root: ffi.Hash(root)}, nil
fmt.Printf("Firewood Reader created at %p\n", revision)
return &reader{revision: revision}, nil
}

// reader is a state reader of Database which implements the Reader interface.
type reader struct {
db *Database
root ffi.Hash // The root of the state this reader is reading.
revision *ffi.Revision
}

// Node retrieves the trie node with the given node hash. No error will be
Expand All @@ -511,7 +512,7 @@ func (reader *reader) Node(_ common.Hash, path []byte, _ common.Hash) ([]byte, e
// This function relies on Firewood's internal locking to ensure concurrent reads are safe.
// This is safe even if a proposal is being committed concurrently.
start := time.Now()
result, err := reader.db.fwDisk.GetFromRoot(reader.root, path)
result, err := reader.revision.Get(path)
if metrics.EnabledExpensive {
ffiReadCount.Inc(1)
ffiReadTimer.Inc(time.Since(start).Milliseconds())
Expand Down
Loading