mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
les: fix nextRequest best variables selection
This commit is contained in:
parent
14346e4ef9
commit
667f5eca14
1 changed files with 2 additions and 1 deletions
|
|
@ -410,6 +410,7 @@ func (f *lightFetcher) nextRequest() (*distReq, uint64) {
|
||||||
bestHash common.Hash
|
bestHash common.Hash
|
||||||
bestAmount uint64
|
bestAmount uint64
|
||||||
)
|
)
|
||||||
|
bestAmount--
|
||||||
bestTd := f.maxConfirmedTd
|
bestTd := f.maxConfirmedTd
|
||||||
bestSyncing := false
|
bestSyncing := false
|
||||||
|
|
||||||
|
|
@ -417,7 +418,7 @@ func (f *lightFetcher) nextRequest() (*distReq, uint64) {
|
||||||
for hash, n := range fp.nodeByHash {
|
for hash, n := range fp.nodeByHash {
|
||||||
if !f.checkKnownNode(p, n) && !n.requested && (bestTd == nil || n.td.Cmp(bestTd) >= 0) {
|
if !f.checkKnownNode(p, n) && !n.requested && (bestTd == nil || n.td.Cmp(bestTd) >= 0) {
|
||||||
amount := f.requestAmount(p, n)
|
amount := f.requestAmount(p, n)
|
||||||
if bestTd == nil || n.td.Cmp(bestTd) > 0 || amount < bestAmount {
|
if amount < bestAmount {
|
||||||
bestHash = hash
|
bestHash = hash
|
||||||
bestAmount = amount
|
bestAmount = amount
|
||||||
bestTd = n.td
|
bestTd = n.td
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue