core, eth, trie: use common/prque (#17508)

This commit is contained in:
Wenbiao Zheng
2018-09-03 23:33:21 +08:00
committed by Felix Lange
parent 6fc8494620
commit 6a33954731
10 changed files with 30 additions and 327 deletions

View File

@ -21,8 +21,8 @@ import (
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/prque"
"github.com/ethereum/go-ethereum/ethdb"
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
)
// ErrNotRequested is returned by the trie sync when it's requested to process a
@ -84,7 +84,7 @@ func NewSync(root common.Hash, database DatabaseReader, callback LeafCallback) *
database: database,
membatch: newSyncMemBatch(),
requests: make(map[common.Hash]*request),
queue: prque.New(),
queue: prque.New(nil),
}
ts.AddSubTrie(root, 0, common.Hash{}, callback)
return ts
@ -242,7 +242,7 @@ func (s *Sync) schedule(req *request) {
return
}
// Schedule the request for future retrieval
s.queue.Push(req.hash, float32(req.depth))
s.queue.Push(req.hash, int64(req.depth))
s.requests[req.hash] = req
}