/
slashing.go
66 lines (57 loc) · 1.57 KB
/
slashing.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
58
59
60
61
62
63
64
65
66
package dpos
import (
"errors"
"gopkg.in/urfave/cli.v1"
"github.com/PhoenixGlobal/Phoenix-Chain-Core/ethereum/p2p/discover"
)
var (
SlashingCmd = cli.Command{
Name: "slashing",
Usage: "use for slashing",
Subcommands: []cli.Command{
checkDuplicateSignCmd,
zeroProduceNodeListCmd,
},
}
checkDuplicateSignCmd = cli.Command{
Name: "checkDuplicateSign",
Usage: "3001,query whether the node has been reported for too many signatures,parameter:duplicateSignType,nodeid,blockNum",
Before: netCheck,
Action: checkDuplicateSign,
Flags: []cli.Flag{rpcUrlFlag, addressHRPFlag,
cli.Uint64Flag{
Name: "duplicateSignType",
Usage: "duplicateSign type,1:prepareBlock,2:prepareVote,3:viewChange",
},
nodeIdFlag,
blockNumFlag, jsonFlag,
},
}
zeroProduceNodeListCmd = cli.Command{
Name: "zeroProduceNodeList",
Usage: "3002,query the list of nodes with zero block",
Before: netCheck,
Action: zeroProduceNodeList,
Flags: []cli.Flag{rpcUrlFlag, addressHRPFlag, jsonFlag},
}
blockNumFlag = cli.Uint64Flag{
Name: "blockNum",
Usage: "blockNum",
}
)
func checkDuplicateSign(c *cli.Context) error {
duplicateSignType := c.Uint64("duplicateSignType")
nodeIDstring := c.String(nodeIdFlag.Name)
if nodeIDstring == "" {
return errors.New("The reported node ID is not set")
}
nodeid, err := discover.HexID(nodeIDstring)
if err != nil {
return err
}
blockNum := c.Uint64(blockNumFlag.Name)
return query(c, 3001, uint32(duplicateSignType), nodeid, blockNum)
}
func zeroProduceNodeList(c *cli.Context) error {
return query(c, 3002)
}