cli/server: dump genesis block state when restoring
Neo 3 node does it too and it's very useful because now the genesis block also does some state changes that are important.
This commit is contained in:
parent
21cb7d5701
commit
176c0e98d6
2 changed files with 13 additions and 10 deletions
|
@ -292,16 +292,19 @@ func restoreDB(ctx *cli.Context) error {
|
|||
genesis, err := chain.GetBlock(block.Hash())
|
||||
if err == nil && genesis.Index == 0 {
|
||||
log.Info("skipped genesis block", zap.String("hash", block.Hash().StringLE()))
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
err = chain.AddBlock(block)
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("failed to add block %d: %s", i, err), 1)
|
||||
}
|
||||
}
|
||||
err = chain.AddBlock(block)
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("failed to add block %d: %s", i, err), 1)
|
||||
}
|
||||
|
||||
if dumpDir != "" {
|
||||
batch := chain.LastBatch()
|
||||
// The genesis block may already be persisted, so LastBatch() will return nil.
|
||||
if batch == nil && block.Index == 0 {
|
||||
continue
|
||||
}
|
||||
dump.add(block.Index, batch)
|
||||
lastIndex = block.Index
|
||||
if block.Index%1000 == 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue