aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2019-04-25 16:31:23 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-04-25 16:31:23 +0800
commit749ccab9a4fb778c144f2e435249a8bb697e974e (patch)
tree71bbd22f3a4cdc883b36d4fafce7eaf8e6efdb29
parent6269e5574c024bb82617b33f673550231b3a3b37 (diff)
downloadgo-tangerine-749ccab9a4fb778c144f2e435249a8bb697e974e.tar
go-tangerine-749ccab9a4fb778c144f2e435249a8bb697e974e.tar.gz
go-tangerine-749ccab9a4fb778c144f2e435249a8bb697e974e.tar.bz2
go-tangerine-749ccab9a4fb778c144f2e435249a8bb697e974e.tar.lz
go-tangerine-749ccab9a4fb778c144f2e435249a8bb697e974e.tar.xz
go-tangerine-749ccab9a4fb778c144f2e435249a8bb697e974e.tar.zst
go-tangerine-749ccab9a4fb778c144f2e435249a8bb697e974e.zip
eth/downloader: enable unsync-protection for light client (#19496)
* eth/downloader: enable unsync-protection for light client * eth/downloader: fix tests
-rw-r--r--eth/downloader/downloader.go2
-rw-r--r--eth/downloader/downloader_test.go4
2 files changed, 3 insertions, 3 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index d94bfa27e..099eb5f47 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -580,7 +580,7 @@ func (d *Downloader) fetchHeight(p *peerConnection) (*types.Header, error) {
return nil, errBadPeer
}
head := headers[0]
- if d.mode == FastSync && head.Number.Uint64() < d.checkpoint {
+ if (d.mode == FastSync || d.mode == LightSync) && head.Number.Uint64() < d.checkpoint {
p.log.Warn("Remote head below checkpoint", "number", head.Number, "hash", head.Hash())
return nil, errUnsyncedPeer
}
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go
index f8c6b2585..ec45eb06d 100644
--- a/eth/downloader/downloader_test.go
+++ b/eth/downloader/downloader_test.go
@@ -1594,13 +1594,13 @@ func testCheckpointEnforcement(t *testing.T, protocol int, mode SyncMode) {
tester.newPeer("peer", protocol, chain)
var expect error
- if mode == FastSync {
+ if mode == FastSync || mode == LightSync {
expect = errUnsyncedPeer
}
if err := tester.sync("peer", nil, mode); err != expect {
t.Fatalf("block sync error mismatch: have %v, want %v", err, expect)
}
- if mode == FastSync {
+ if mode == FastSync || mode == LightSync {
assertOwnChain(t, tester, 1)
} else {
assertOwnChain(t, tester, chain.len())