add slash-consensus from flag

This commit is contained in:
zgfzgf 2021-01-19 14:18:46 +08:00
parent 2b3d66da3b
commit 29bdd94b12

View File

@ -1105,6 +1105,10 @@ var slashConsensusFault = &cli.Command{
Usage: "Report consensus fault",
ArgsUsage: "[blockCid1 blockCid2]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "from",
Usage: "optionally specify the account to report consensus from",
},
&cli.StringFlag{
Name: "extra",
Usage: "Extra block cid",
@ -1142,11 +1146,23 @@ var slashConsensusFault = &cli.Command{
return xerrors.Errorf("block1.miner:%s block2.miner:%s", b1.Miner, b2.Miner)
}
def, err := api.WalletDefaultAddress(ctx)
var fromAddr address.Address
if from := cctx.String("from"); from == "" {
defaddr, err := api.WalletDefaultAddress(ctx)
if err != nil {
return err
}
fromAddr = defaddr
} else {
addr, err := address.NewFromString(from)
if err != nil {
return err
}
fromAddr = addr
}
bh1, err := cborutil.Dump(b1)
if err != nil {
return err
@ -1188,7 +1204,7 @@ var slashConsensusFault = &cli.Command{
msg := &types.Message{
To: b2.Miner,
From: def,
From: fromAddr,
Value: types.NewInt(0),
Method: builtin.MethodsMiner.ReportConsensusFault,
Params: enc,