forked from TrueCloudLab/neoneo-go
cli: allow to use incremental dumps in db restore
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
05cb6586a6
commit
df5ee4abdc
1 changed files with 14 additions and 0 deletions
|
@ -64,6 +64,10 @@ func NewCommands() []cli.Command {
|
|||
Name: "dump",
|
||||
Usage: "directory for storing JSON dumps",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "incremental, n",
|
||||
Usage: "use if dump is incremental",
|
||||
},
|
||||
)
|
||||
return []cli.Command{
|
||||
{
|
||||
|
@ -240,6 +244,16 @@ func restoreDB(ctx *cli.Context) error {
|
|||
defer prometheus.ShutDown()
|
||||
defer pprof.ShutDown()
|
||||
|
||||
var start uint32
|
||||
if ctx.Bool("incremental") {
|
||||
start = reader.ReadU32LE()
|
||||
if chain.BlockHeight()+1 < start {
|
||||
return cli.NewExitError(fmt.Errorf("expected height: %d, dump starts at %d",
|
||||
chain.BlockHeight()+1, start), 1)
|
||||
}
|
||||
skip = chain.BlockHeight() + 1 - start
|
||||
}
|
||||
|
||||
var allBlocks = reader.ReadU32LE()
|
||||
if reader.Err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
|
Loading…
Reference in a new issue