aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-04-28 18:57:57 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-04-28 18:57:57 +0800
commitb569550a391d867b8c600d43e645220396d3a17e (patch)
tree77ccafde144d30a79f119152543c6f5c1d4f80c5 /p2p
parent91cb8cdd2acdcaceb577fd0ea9eb0997d42f8470 (diff)
downloaddexon-b569550a391d867b8c600d43e645220396d3a17e.tar.gz
dexon-b569550a391d867b8c600d43e645220396d3a17e.tar.zst
dexon-b569550a391d867b8c600d43e645220396d3a17e.zip
p2p/discover: fix api issues caused by leveldb update
Diffstat (limited to 'p2p')
-rw-r--r--p2p/discover/database.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/p2p/discover/database.go b/p2p/discover/database.go
index d966a6ac1..964f86b84 100644
--- a/p2p/discover/database.go
+++ b/p2p/discover/database.go
@@ -14,8 +14,10 @@ import (
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rlp"
"github.com/syndtr/goleveldb/leveldb"
+ "github.com/syndtr/goleveldb/leveldb/errors"
"github.com/syndtr/goleveldb/leveldb/iterator"
"github.com/syndtr/goleveldb/leveldb/storage"
+ "github.com/syndtr/goleveldb/leveldb/util"
)
var (
@@ -71,7 +73,7 @@ func newMemoryNodeDB() (*nodeDB, error) {
func newPersistentNodeDB(path string, version int) (*nodeDB, error) {
// Try to open the cache, recovering any corruption
db, err := leveldb.OpenFile(path, nil)
- if _, iscorrupted := err.(leveldb.ErrCorrupted); iscorrupted {
+ if _, iscorrupted := err.(*errors.ErrCorrupted); iscorrupted {
db, err = leveldb.RecoverFile(path, nil)
}
if err != nil {
@@ -227,9 +229,9 @@ func (db *nodeDB) expireNodes() error {
continue
}
// Otherwise delete all associated information
- prefix := makeKey(id, "")
- for ok := it.Seek(prefix); ok && bytes.HasPrefix(it.Key(), prefix); ok = it.Next() {
- if err := db.lvl.Delete(it.Key(), nil); err != nil {
+ deleter := db.lvl.NewIterator(util.BytesPrefix(makeKey(id, "")), nil)
+ for deleter.Next() {
+ if err := db.lvl.Delete(deleter.Key(), nil); err != nil {
return err
}
}