aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorWenbiao Zheng <delweng@gmail.com>2018-09-30 04:13:39 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-09-30 04:13:39 +0800
commit024b22c30e1b40b702f8f7b0831baebce333c8db (patch)
treef0fd48844351cd18730a6605338c01a6154d187d /eth
parentffca6dfe0162074cb9224a26aa667ac724be0ab8 (diff)
downloadgo-tangerine-024b22c30e1b40b702f8f7b0831baebce333c8db.tar
go-tangerine-024b22c30e1b40b702f8f7b0831baebce333c8db.tar.gz
go-tangerine-024b22c30e1b40b702f8f7b0831baebce333c8db.tar.bz2
go-tangerine-024b22c30e1b40b702f8f7b0831baebce333c8db.tar.lz
go-tangerine-024b22c30e1b40b702f8f7b0831baebce333c8db.tar.xz
go-tangerine-024b22c30e1b40b702f8f7b0831baebce333c8db.tar.zst
go-tangerine-024b22c30e1b40b702f8f7b0831baebce333c8db.zip
eth/downloader: use intermediate variable for better readability (#17510)
Diffstat (limited to 'eth')
-rw-r--r--eth/downloader/downloader.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index fbde9c6ca..805195034 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -658,8 +658,10 @@ func (d *Downloader) findAncestor(p *peerConnection, height uint64) (uint64, err
continue
}
// Otherwise check if we already know the header or not
- if (d.mode == FullSync && d.blockchain.HasBlock(headers[i].Hash(), headers[i].Number.Uint64())) || (d.mode != FullSync && d.lightchain.HasHeader(headers[i].Hash(), headers[i].Number.Uint64())) {
- number, hash = headers[i].Number.Uint64(), headers[i].Hash()
+ h := headers[i].Hash()
+ n := headers[i].Number.Uint64()
+ if (d.mode == FullSync && d.blockchain.HasBlock(h, n)) || (d.mode != FullSync && d.lightchain.HasHeader(h, n)) {
+ number, hash = n, h
// If every header is known, even future ones, the peer straight out lied about its head
if number > height && i == limit-1 {
@@ -723,11 +725,13 @@ func (d *Downloader) findAncestor(p *peerConnection, height uint64) (uint64, err
arrived = true
// Modify the search interval based on the response
- if (d.mode == FullSync && !d.blockchain.HasBlock(headers[0].Hash(), headers[0].Number.Uint64())) || (d.mode != FullSync && !d.lightchain.HasHeader(headers[0].Hash(), headers[0].Number.Uint64())) {
+ h := headers[0].Hash()
+ n := headers[0].Number.Uint64()
+ if (d.mode == FullSync && !d.blockchain.HasBlock(h, n)) || (d.mode != FullSync && !d.lightchain.HasHeader(h, n)) {
end = check
break
}
- header := d.lightchain.GetHeaderByHash(headers[0].Hash()) // Independent of sync mode, header surely exists
+ header := d.lightchain.GetHeaderByHash(h) // Independent of sync mode, header surely exists
if header.Number.Uint64() != check {
p.log.Debug("Received non requested header", "number", header.Number, "hash", header.Hash(), "request", check)
return 0, errBadPeer