mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-03-19 17:40:42 +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 height <= uint64(fsMinFullBlocks) {
|
||||
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 {
|
||||
pivotNumber := pivot.Number.Uint64()
|
||||
if pivotNumber <= origin {
|
||||
|
|
|
|||
|
|
@ -177,7 +177,11 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
|||
}
|
||||
} else {
|
||||
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.
|
||||
log.Warn("Switch sync mode from snap sync to full sync", "reason", "snap sync complete")
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue