Merge pull request #5378 from zgfzgf/feat-chain-consensus
add slash-consensus from flag
This commit is contained in:
commit
6bccdcc177
20
cli/chain.go
20
cli/chain.go
@ -1105,6 +1105,10 @@ var slashConsensusFault = &cli.Command{
|
|||||||
Usage: "Report consensus fault",
|
Usage: "Report consensus fault",
|
||||||
ArgsUsage: "[blockCid1 blockCid2]",
|
ArgsUsage: "[blockCid1 blockCid2]",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "from",
|
||||||
|
Usage: "optionally specify the account to report consensus from",
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "extra",
|
Name: "extra",
|
||||||
Usage: "Extra block cid",
|
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)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fromAddr = defaddr
|
||||||
|
} else {
|
||||||
|
addr, err := address.NewFromString(from)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fromAddr = addr
|
||||||
|
}
|
||||||
|
|
||||||
bh1, err := cborutil.Dump(b1)
|
bh1, err := cborutil.Dump(b1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -1188,7 +1204,7 @@ var slashConsensusFault = &cli.Command{
|
|||||||
|
|
||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
To: b2.Miner,
|
To: b2.Miner,
|
||||||
From: def,
|
From: fromAddr,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
Method: builtin.MethodsMiner.ReportConsensusFault,
|
Method: builtin.MethodsMiner.ReportConsensusFault,
|
||||||
Params: enc,
|
Params: enc,
|
||||||
|
Loading…
Reference in New Issue
Block a user