-
Notifications
You must be signed in to change notification settings - Fork 10
/
replaystates.go
57 lines (49 loc) · 1.13 KB
/
replaystates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2017 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"os"
"strconv"
"github.com/FactomProject/factom"
)
var replaydbstates = func() *fctCmd {
cmd := new(fctCmd)
cmd.helpMsg = "factom-cli replaydbstates STARTHEIGHT ENDHEIGHT"
cmd.description = "Emit DBStateMsgs over the LiveFeed API between two specifed block heights"
cmd.execFunc = func(args []string) {
os.Args = args
flag.Parse()
args = flag.Args()
if len(args) < 1 || len(args) > 2 {
fmt.Println(cmd.helpMsg)
return
}
startHeightStr, err := strconv.ParseInt(args[0], 10, 32)
if err != nil {
errorln(err)
return
}
startheight := startHeightStr
var endheight int64
endheight = 0
if len(args) == 2 {
endHeightStr, err := strconv.ParseInt(args[1], 10, 32)
if err != nil {
errorln(err)
return
}
endheight = endHeightStr
}
res, err := factom.ReplayDBlockFromHeight(startheight, endheight)
if err != nil {
errorln(err)
return
}
fmt.Println(res.Message)
}
help.Add("replaydbstates", cmd)
return cmd
}()