add a from flag for miner init
This commit is contained in:
parent
885f357c59
commit
2675ffb128
@ -7,12 +7,13 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
|
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
@ -107,6 +108,10 @@ var initCmd = &cli.Command{
|
|||||||
Usage: "set gas premium for initialization messages in AttoFIL",
|
Usage: "set gas premium for initialization messages in AttoFIL",
|
||||||
Value: "0",
|
Value: "0",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "from",
|
||||||
|
Usage: "select which address to send actor creation message from",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
log.Info("Initializing lotus miner")
|
log.Info("Initializing lotus miner")
|
||||||
@ -631,9 +636,18 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
|||||||
return address.Undef, err
|
return address.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sender := owner
|
||||||
|
if fromstr := cctx.String("from"); fromstr != "" {
|
||||||
|
faddr, err := address.NewFromString(fromstr)
|
||||||
|
if err != nil {
|
||||||
|
return address.Undef, fmt.Errorf("could not parse from address: %w", err)
|
||||||
|
}
|
||||||
|
sender = faddr
|
||||||
|
}
|
||||||
|
|
||||||
createStorageMinerMsg := &types.Message{
|
createStorageMinerMsg := &types.Message{
|
||||||
To: builtin.StoragePowerActorAddr,
|
To: builtin.StoragePowerActorAddr,
|
||||||
From: owner,
|
From: sender,
|
||||||
Value: big.Zero(),
|
Value: big.Zero(),
|
||||||
|
|
||||||
Method: builtin.MethodsPower.CreateMiner,
|
Method: builtin.MethodsPower.CreateMiner,
|
||||||
|
Loading…
Reference in New Issue
Block a user