aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-05-14 21:01:13 +0800
committerFelix Lange <fjl@twurst.com>2015-05-14 21:01:13 +0800
commitd2f119cf9b30a7568b5ebe7c290c3be30dc0f2de (patch)
tree61cf62475fb7d874877c38ae74a1d38a54053578 /p2p
parent206fe259718c015df43dd25b59a9dfd370428b53 (diff)
downloaddexon-d2f119cf9b30a7568b5ebe7c290c3be30dc0f2de.tar.gz
dexon-d2f119cf9b30a7568b5ebe7c290c3be30dc0f2de.tar.zst
dexon-d2f119cf9b30a7568b5ebe7c290c3be30dc0f2de.zip
p2p/discover: limit open files for node database
Diffstat (limited to 'p2p')
-rw-r--r--p2p/discover/database.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/p2p/discover/database.go b/p2p/discover/database.go
index dc0b97ddf..2b9da0423 100644
--- a/p2p/discover/database.go
+++ b/p2p/discover/database.go
@@ -17,6 +17,7 @@ import (
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/errors"
"github.com/syndtr/goleveldb/leveldb/iterator"
+ "github.com/syndtr/goleveldb/leveldb/opt"
"github.com/syndtr/goleveldb/leveldb/storage"
"github.com/syndtr/goleveldb/leveldb/util"
)
@@ -72,8 +73,8 @@ func newMemoryNodeDB() (*nodeDB, error) {
// newPersistentNodeDB creates/opens a leveldb backed persistent node database,
// also flushing its contents in case of a version mismatch.
func newPersistentNodeDB(path string, version int) (*nodeDB, error) {
- // Try to open the cache, recovering any corruption
- db, err := leveldb.OpenFile(path, nil)
+ opts := &opt.Options{OpenFilesCacheCapacity: 5}
+ db, err := leveldb.OpenFile(path, opts)
if _, iscorrupted := err.(*errors.ErrCorrupted); iscorrupted {
db, err = leveldb.RecoverFile(path, nil)
}