mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
core, ethdb: fix a flaw in SetHeadWithTimestamp
This commit is contained in:
parent
546af1adc1
commit
cbd8ffcc3a
2 changed files with 7 additions and 3 deletions
|
|
@ -625,8 +625,12 @@ func (hc *HeaderChain) setHead(headBlock uint64, headTime uint64, updateFn Updat
|
||||||
if delFn != nil {
|
if delFn != nil {
|
||||||
// Ignore the error here since light client won't hit this path
|
// Ignore the error here since light client won't hit this path
|
||||||
frozen, _ := hc.chainDb.Ancients()
|
frozen, _ := hc.chainDb.Ancients()
|
||||||
if headBlock+1 < frozen {
|
header := hc.CurrentHeader()
|
||||||
_, err := hc.chainDb.TruncateHead(headBlock + 1)
|
|
||||||
|
// Truncate the excessive chain segment above the current chain head
|
||||||
|
// in the ancient store.
|
||||||
|
if header.Number.Uint64()+1 < frozen {
|
||||||
|
_, err := hc.chainDb.TruncateHead(header.Number.Uint64() + 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Crit("Failed to truncate head block", "err", err)
|
log.Crit("Failed to truncate head block", "err", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ type KeyValueStater interface {
|
||||||
Stat() (string, error)
|
Stat() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyValueSyncer wraps the Sync method of a backing data store.
|
// KeyValueSyncer wraps the SyncKeyValue method of a backing data store.
|
||||||
type KeyValueSyncer interface {
|
type KeyValueSyncer interface {
|
||||||
// SyncKeyValue ensures that all pending writes are flushed to disk,
|
// SyncKeyValue ensures that all pending writes are flushed to disk,
|
||||||
// guaranteeing data durability up to the point.
|
// guaranteeing data durability up to the point.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue