Merge pull request #3178 from filecoin-project/feat/miner-init-from-flag

add a from flag for miner init
This commit is contained in:
Łukasz Magiera 2020-08-20 17:09:03 +02:00 committed by GitHub
commit 364e3229b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,12 +7,13 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/docker/go-units"
"github.com/google/uuid"
"github.com/ipfs/go-datastore"
@ -107,6 +108,10 @@ var initCmd = &cli.Command{
Usage: "set gas premium for initialization messages in AttoFIL",
Value: "0",
},
&cli.StringFlag{
Name: "from",
Usage: "select which address to send actor creation message from",
},
},
Action: func(cctx *cli.Context) error {
log.Info("Initializing lotus miner")
@ -631,9 +636,18 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
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{
To: builtin.StoragePowerActorAddr,
From: owner,
From: sender,
Value: big.Zero(),
Method: builtin.MethodsPower.CreateMiner,