mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
fix lint
This commit is contained in:
parent
c7cd97fe1c
commit
dc16ec33ee
1 changed files with 26 additions and 29 deletions
|
|
@ -248,38 +248,35 @@ func (sf *subfetcher) loop() {
|
||||||
sf.trie = trie
|
sf.trie = trie
|
||||||
}
|
}
|
||||||
// Trie opened successfully, keep prefetching items
|
// Trie opened successfully, keep prefetching items
|
||||||
for {
|
for keepRunning := range sf.wake {
|
||||||
select {
|
// Subfetcher was woken up, retrieve any tasks to avoid spinning the lock
|
||||||
case keepRunning := <-sf.wake:
|
sf.lock.Lock()
|
||||||
// Subfetcher was woken up, retrieve any tasks to avoid spinning the lock
|
tasks := sf.tasks
|
||||||
sf.lock.Lock()
|
sf.tasks = nil
|
||||||
tasks := sf.tasks
|
sf.lock.Unlock()
|
||||||
sf.tasks = nil
|
|
||||||
sf.lock.Unlock()
|
|
||||||
|
|
||||||
// Prefetch all tasks
|
// Prefetch all tasks
|
||||||
for _, task := range tasks {
|
for _, task := range tasks {
|
||||||
if _, ok := sf.seen[string(task)]; ok {
|
if _, ok := sf.seen[string(task)]; ok {
|
||||||
sf.dups++
|
sf.dups++
|
||||||
continue
|
continue
|
||||||
}
|
|
||||||
if len(task) == common.AddressLength {
|
|
||||||
sf.trie.GetAccount(common.BytesToAddress(task))
|
|
||||||
} else {
|
|
||||||
sf.trie.GetStorage(sf.addr, task)
|
|
||||||
}
|
|
||||||
sf.seen[string(task)] = struct{}{}
|
|
||||||
}
|
}
|
||||||
// if any trie retrieval request is made, ensure it is completed
|
if len(task) == common.AddressLength {
|
||||||
// after pending tasks have been processed.
|
sf.trie.GetAccount(common.BytesToAddress(task))
|
||||||
select {
|
} else {
|
||||||
case ch := <-sf.copy:
|
sf.trie.GetStorage(sf.addr, task)
|
||||||
ch <- sf.db.CopyTrie(sf.trie)
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
if !keepRunning {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
sf.seen[string(task)] = struct{}{}
|
||||||
|
}
|
||||||
|
// if any trie retrieval request is made, ensure it is completed
|
||||||
|
// after pending tasks have been processed.
|
||||||
|
select {
|
||||||
|
case ch := <-sf.copy:
|
||||||
|
ch <- sf.db.CopyTrie(sf.trie)
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
if !keepRunning {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue