aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2019-05-14 22:07:44 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-05-16 15:39:34 +0800
commit37d280da411eb649ce22ab69827ac5aacd46534b (patch)
tree8d19d2071c812575a14cea54a2de9efd2dd33157 /eth/downloader
parent42c746d6f405deb0c49d868dcc6e0afe279e19ab (diff)
downloadgo-tangerine-37d280da411eb649ce22ab69827ac5aacd46534b.tar
go-tangerine-37d280da411eb649ce22ab69827ac5aacd46534b.tar.gz
go-tangerine-37d280da411eb649ce22ab69827ac5aacd46534b.tar.bz2
go-tangerine-37d280da411eb649ce22ab69827ac5aacd46534b.tar.lz
go-tangerine-37d280da411eb649ce22ab69827ac5aacd46534b.tar.xz
go-tangerine-37d280da411eb649ce22ab69827ac5aacd46534b.tar.zst
go-tangerine-37d280da411eb649ce22ab69827ac5aacd46534b.zip
core, cmd, vendor: fixes and database inspection tool (#15)
* core, eth: some fixes for freezer * vendor, core/rawdb, cmd/geth: add db inspector * core, cmd/utils: check ancient store path forceily * cmd/geth, common, core/rawdb: a few fixes * cmd/geth: support windows file rename and fix rename error * core: support ancient plugin * core, cmd: streaming file copy * cmd, consensus, core, tests: keep genesis in leveldb * core: write txlookup during ancient init * core: bump database version
Diffstat (limited to 'eth/downloader')
-rw-r--r--eth/downloader/downloader.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 79107c8d1..5c350debe 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -478,21 +478,21 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
}
if d.mode == FastSync {
// Set the ancient data limitation.
- // If we are running fast sync, all block data not greater than ancientLimit will
- // be written to the ancient store. Otherwise, block data will be written to active
- // database and then wait freezer to migrate.
+ // If we are running fast sync, all block data older than ancientLimit will be
+ // written to the ancient store. More recent data will be written to the active
+ // database and will wait for the freezer to migrate.
//
- // If there is checkpoint available, then calculate the ancientLimit through
- // checkpoint. Otherwise calculate the ancient limit through the advertised
- // height by remote peer.
+ // If there is a checkpoint available, then calculate the ancientLimit through
+ // that. Otherwise calculate the ancient limit through the advertised height
+ // of the remote peer.
//
- // The reason for picking checkpoint first is: there exists an attack vector
- // for height that: a malicious peer can give us a fake(very high) height,
- // so that the ancient limit is also very high. And then the peer start to
- // feed us valid blocks until head. All of these blocks might be written into
- // the ancient store, the safe region for freezer is not enough.
+ // The reason for picking checkpoint first is that a malicious peer can give us
+ // a fake (very high) height, forcing the ancient limit to also be very high.
+ // The peer would start to feed us valid blocks until head, resulting in all of
+ // the blocks might be written into the ancient store. A following mini-reorg
+ // could cause issues.
if d.checkpoint != 0 && d.checkpoint > MaxForkAncestry+1 {
- d.ancientLimit = height - MaxForkAncestry - 1
+ d.ancientLimit = d.checkpoint
} else if height > MaxForkAncestry+1 {
d.ancientLimit = height - MaxForkAncestry - 1
}