mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
add comment
This commit is contained in:
parent
bd697bc671
commit
5845427d0d
1 changed files with 3 additions and 2 deletions
|
|
@ -55,8 +55,6 @@ func New(datadir string) (*EraDatabase, error) {
|
|||
return nil, err
|
||||
}
|
||||
db := &EraDatabase{datadir: datadir, cache: lru.NewCache[uint64, *era.Era](openFileLimit)}
|
||||
// Take care to close era1 files when they are evicted or replaced
|
||||
// in the cache to avoid leaking file descriptors.
|
||||
closeEra := func(epoch uint64, e *era.Era) {
|
||||
if e == nil {
|
||||
log.Warn("Era1 cache contained nil value", "epoch", epoch)
|
||||
|
|
@ -67,7 +65,10 @@ func New(datadir string) (*EraDatabase, error) {
|
|||
}
|
||||
|
||||
}
|
||||
// Take care to close era1 files when they are evicted from cache.
|
||||
db.cache.OnEvicted(closeEra)
|
||||
// Concurrently calling GetRaw* methods can cause the same era1 file to be
|
||||
// opened multiple times.
|
||||
db.cache.OnReplaced(closeEra)
|
||||
log.Info("Opened erastore", "datadir", datadir)
|
||||
return db, nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue