Skip to content

Commit 4214a7b

Browse files
committed
eth/downloader: dynamically move pivot even during chain sync ethereum#21529
1 parent bc7e213 commit 4214a7b

File tree

5 files changed

+210
-64
lines changed

5 files changed

+210
-64
lines changed

core/rawdb/accessors_chain.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@ func WriteFastTrieProgress(db ethdb.KeyValueWriter, count uint64) error {
164164
return nil
165165
}
166166

167+
// WriteLastPivotNumber stores the number of the last pivot block.
168+
func WriteLastPivotNumber(db ethdb.KeyValueWriter, pivot uint64) {
169+
enc, err := rlp.EncodeToBytes(pivot)
170+
if err != nil {
171+
log.Crit("Failed to encode pivot block number", "err", err)
172+
}
173+
if err := db.Put(lastPivotKey, enc); err != nil {
174+
log.Crit("Failed to store pivot block number", "err", err)
175+
}
176+
}
177+
167178
// ReadHeaderRLP retrieves a block header in its raw RLP database encoding.
168179
func ReadHeaderRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue {
169180
// First try to look up the data in ancient database. Extra hash

core/rawdb/schema.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ var (
3939
// headFastBlockKey tracks the latest known incomplete block's hash during fast sync.
4040
headFastBlockKey = []byte("LastFast")
4141

42+
// lastPivotKey tracks the last pivot block used by fast sync (to reenable on sethead).
43+
lastPivotKey = []byte("LastPivot")
44+
4245
// fastTrieProgressKey tracks the number of trie entries imported during fast sync.
4346
fastTrieProgressKey = []byte("TrieSync")
4447

0 commit comments

Comments
 (0)