mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
Using full sync for genesis block
This commit is contained in:
parent
e67761ef35
commit
58bdd555c7
2 changed files with 11 additions and 1 deletions
|
|
@ -485,6 +485,12 @@ func (d *Downloader) syncToHead() (err error) {
|
||||||
if mode == ethconfig.SnapSync {
|
if mode == ethconfig.SnapSync {
|
||||||
if height <= uint64(fsMinFullBlocks) {
|
if height <= uint64(fsMinFullBlocks) {
|
||||||
origin = 0
|
origin = 0
|
||||||
|
// For genesis block, switch to full sync
|
||||||
|
if height == 0 {
|
||||||
|
mode = ethconfig.FullSync
|
||||||
|
d.mode.Store(uint32(mode))
|
||||||
|
log.Info("Switching to full sync for genesis block")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pivotNumber := pivot.Number.Uint64()
|
pivotNumber := pivot.Number.Uint64()
|
||||||
if pivotNumber <= origin {
|
if pivotNumber <= origin {
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,11 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
head := h.chain.CurrentBlock()
|
head := h.chain.CurrentBlock()
|
||||||
if head.Number.Uint64() > 0 && h.chain.HasState(head.Root) {
|
if head.Number.Uint64() == 0 {
|
||||||
|
// For genesis block, always use full sync
|
||||||
|
h.snapSync.Store(false)
|
||||||
|
log.Info("Using full sync for genesis block")
|
||||||
|
} else if head.Number.Uint64() > 0 && h.chain.HasState(head.Root) {
|
||||||
// Print warning log if database is not empty to run snap sync.
|
// Print warning log if database is not empty to run snap sync.
|
||||||
log.Warn("Switch sync mode from snap sync to full sync", "reason", "snap sync complete")
|
log.Warn("Switch sync mode from snap sync to full sync", "reason", "snap sync complete")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue