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",
|
Name: "dump",
|
||||||
Usage: "directory for storing JSON dumps",
|
Usage: "directory for storing JSON dumps",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "incremental, n",
|
||||||
|
Usage: "use if dump is incremental",
|
||||||
|
},
|
||||||
)
|
)
|
||||||
return []cli.Command{
|
return []cli.Command{
|
||||||
{
|
{
|
||||||
|
@ -240,6 +244,16 @@ func restoreDB(ctx *cli.Context) error {
|
||||||
defer prometheus.ShutDown()
|
defer prometheus.ShutDown()
|
||||||
defer pprof.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()
|
var allBlocks = reader.ReadU32LE()
|
||||||
if reader.Err != nil {
|
if reader.Err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
|
|
Loading…
Reference in a new issue