Merge pull request #5378 from zgfzgf/feat-chain-consensus

add slash-consensus from flag
This commit is contained in:
Łukasz Magiera 2021-01-19 11:39:45 +01:00 committed by GitHub
commit 6bccdcc177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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,9 +1146,21 @@ var slashConsensusFault = &cli.Command{
return xerrors.Errorf("block1.miner:%s block2.miner:%s", b1.Miner, b2.Miner)
}
def, err := api.WalletDefaultAddress(ctx)
if err != nil {
return err
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)
@ -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,