better error (#4907)

Co-authored-by: giuliorebuffo <giuliorebuffo@system76-pc.localdomain>
This commit is contained in:
Giulio rebuffo 2022-08-03 02:49:06 +02:00 committed by GitHub
parent 0640e946dd
commit 311d18ae92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -156,7 +156,11 @@ type GenesisMismatchError struct {
}
func (e *GenesisMismatchError) Error() string {
return fmt.Sprintf("database contains incompatible genesis (have %x, new %x)", e.Stored, e.New)
config := params.ChainConfigByGenesisHash(e.Stored)
if config == nil {
return fmt.Sprintf("database contains incompatible genesis (have %x, new %x)", e.Stored, e.New)
}
return fmt.Sprintf("database contains incompatible genesis (try with --chain=%s)", config.ChainName)
}
// CommitGenesisBlock writes or updates the genesis block in db.