mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
const for open file limit
This commit is contained in:
parent
3f91617093
commit
7c715904b7
1 changed files with 6 additions and 3 deletions
|
|
@ -33,11 +33,14 @@ import (
|
||||||
* - FD leak possible on concurrent access to GetRaw*.
|
* - FD leak possible on concurrent access to GetRaw*.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const (
|
||||||
|
openFileLimit = 64
|
||||||
|
)
|
||||||
|
|
||||||
// EraDatabase manages read access to a directory of era1 files.
|
// EraDatabase manages read access to a directory of era1 files.
|
||||||
// The getter methods are thread-safe.
|
// The getter methods are thread-safe.
|
||||||
type EraDatabase struct {
|
type EraDatabase struct {
|
||||||
datadir string
|
datadir string
|
||||||
// TODO: should take into account configured number of fd handles.
|
|
||||||
cache *lru.Cache[uint64, *era.Era]
|
cache *lru.Cache[uint64, *era.Era]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,7 +60,7 @@ func New(datadir string) (*EraDatabase, error) {
|
||||||
if err := os.MkdirAll(datadir, 0755); err != nil {
|
if err := os.MkdirAll(datadir, 0755); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
db := &EraDatabase{datadir: datadir, cache: lru.NewCache[uint64, *era.Era](50)}
|
db := &EraDatabase{datadir: datadir, cache: lru.NewCache[uint64, *era.Era](openFileLimit)}
|
||||||
log.Info("Opened erastore", "datadir", datadir)
|
log.Info("Opened erastore", "datadir", datadir)
|
||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue