Skip to content

Commit

Permalink
Merge pull request #5378 from zgfzgf/feat-chain-consensus
Browse files Browse the repository at this point in the history
add slash-consensus from flag
  • Loading branch information
magik6k authored Jan 19, 2021
2 parents 901079e + 29bdd94 commit 6bccdcc
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions cli/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6bccdcc

Please sign in to comment.