mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
eth/downloader: panic if sync cycle configured with unknown sync mode. remove LightSync mode definition.
This commit is contained in:
parent
5b5023516c
commit
416ae197ad
2 changed files with 9 additions and 12 deletions
|
|
@ -201,6 +201,8 @@ func (d *Downloader) findBeaconAncestor() (uint64, error) {
|
|||
chainHead = d.blockchain.CurrentBlock()
|
||||
case SnapSync:
|
||||
chainHead = d.blockchain.CurrentSnapBlock()
|
||||
default:
|
||||
panic("unknown sync mode")
|
||||
}
|
||||
number := chainHead.Number.Uint64()
|
||||
|
||||
|
|
@ -220,7 +222,7 @@ func (d *Downloader) findBeaconAncestor() (uint64, error) {
|
|||
case SnapSync:
|
||||
linked = d.blockchain.HasFastBlock(beaconTail.ParentHash, beaconTail.Number.Uint64()-1)
|
||||
default:
|
||||
linked = d.blockchain.HasHeader(beaconTail.ParentHash, beaconTail.Number.Uint64()-1)
|
||||
panic("unknown sync mode")
|
||||
}
|
||||
if !linked {
|
||||
// This is a programming error. The chain backfiller was called with a
|
||||
|
|
@ -254,6 +256,8 @@ func (d *Downloader) findBeaconAncestor() (uint64, error) {
|
|||
known = d.blockchain.HasBlock(h.Hash(), n)
|
||||
case SnapSync:
|
||||
known = d.blockchain.HasFastBlock(h.Hash(), n)
|
||||
default:
|
||||
panic("unknown sync mode")
|
||||
}
|
||||
if !known {
|
||||
end = check
|
||||
|
|
|
|||
|
|
@ -23,13 +23,12 @@ import "fmt"
|
|||
type SyncMode uint32
|
||||
|
||||
const (
|
||||
FullSync SyncMode = iota // Synchronise the entire blockchain history from full blocks
|
||||
SnapSync // Download the chain and the state via compact snapshots
|
||||
LightSync // Download only the headers and terminate afterwards
|
||||
FullSync SyncMode = iota // Synchronise the entire blockchain history from full blocks
|
||||
SnapSync // Download the chain and the state via compact snapshots
|
||||
)
|
||||
|
||||
func (mode SyncMode) IsValid() bool {
|
||||
return mode >= FullSync && mode < LightSync
|
||||
return mode == FullSync || mode == SnapSync
|
||||
}
|
||||
|
||||
// String implements the stringer interface.
|
||||
|
|
@ -39,8 +38,6 @@ func (mode SyncMode) String() string {
|
|||
return "full"
|
||||
case SnapSync:
|
||||
return "snap"
|
||||
case LightSync:
|
||||
return "light"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
|
|
@ -52,8 +49,6 @@ func (mode SyncMode) MarshalText() ([]byte, error) {
|
|||
return []byte("full"), nil
|
||||
case SnapSync:
|
||||
return []byte("snap"), nil
|
||||
case LightSync:
|
||||
return []byte("light"), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown sync mode %d", mode)
|
||||
}
|
||||
|
|
@ -65,10 +60,8 @@ func (mode *SyncMode) UnmarshalText(text []byte) error {
|
|||
*mode = FullSync
|
||||
case "snap":
|
||||
*mode = SnapSync
|
||||
case "light":
|
||||
*mode = LightSync
|
||||
default:
|
||||
return fmt.Errorf(`unknown sync mode %q, want "full", "snap" or "light"`, text)
|
||||
return fmt.Errorf(`unknown sync mode %q, want "full" or "snap"`, text)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue