miner: fix init --create-worker-key
This commit is contained in:
parent
0f5aa9ba5c
commit
869d71446d
@ -601,8 +601,6 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID, gasPrice types.BigInt, cctx *cli.Context) (address.Address, error) {
|
func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID, gasPrice types.BigInt, cctx *cli.Context) (address.Address, error) {
|
||||||
log.Info("Creating StorageMarket.CreateStorageMiner message")
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var owner address.Address
|
var owner address.Address
|
||||||
if cctx.String("owner") != "" {
|
if cctx.String("owner") != "" {
|
||||||
@ -625,9 +623,32 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
|||||||
} else if cctx.Bool("create-worker-key") { // TODO: Do we need to force this if owner is Secpk?
|
} else if cctx.Bool("create-worker-key") { // TODO: Do we need to force this if owner is Secpk?
|
||||||
worker, err = api.WalletNew(ctx, types.KTBLS)
|
worker, err = api.WalletNew(ctx, types.KTBLS)
|
||||||
}
|
}
|
||||||
// TODO: Transfer some initial funds to worker
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return address.Undef, err
|
return address.Address{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure the worker account exists on chain
|
||||||
|
_, err = api.StateLookupID(ctx, worker, types.EmptyTSK)
|
||||||
|
if err != nil {
|
||||||
|
signed, err := api.MpoolPushMessage(ctx, &types.Message{
|
||||||
|
From: owner,
|
||||||
|
To: worker,
|
||||||
|
Value: types.NewInt(0),
|
||||||
|
}, nil)
|
||||||
|
if err != nil {
|
||||||
|
return address.Undef, xerrors.Errorf("push worker init: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("Initializing worker account %s, message: %s", worker, signed.Cid())
|
||||||
|
log.Infof("Waiting for confirmation")
|
||||||
|
|
||||||
|
mw, err := api.StateWaitMsg(ctx, signed.Cid(), build.MessageConfidence)
|
||||||
|
if err != nil {
|
||||||
|
return address.Undef, xerrors.Errorf("waiting for worker init: %w", err)
|
||||||
|
}
|
||||||
|
if mw.Receipt.ExitCode != 0 {
|
||||||
|
return address.Undef, xerrors.Errorf("initializing worker account failed: exit code %d", mw.Receipt.ExitCode)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spt, err := ffiwrapper.SealProofTypeFromSectorSize(abi.SectorSize(ssize))
|
spt, err := ffiwrapper.SealProofTypeFromSectorSize(abi.SectorSize(ssize))
|
||||||
@ -668,15 +689,15 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
|||||||
|
|
||||||
signed, err := api.MpoolPushMessage(ctx, createStorageMinerMsg, nil)
|
signed, err := api.MpoolPushMessage(ctx, createStorageMinerMsg, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return address.Undef, err
|
return address.Undef, xerrors.Errorf("pushing createMiner message: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Pushed StorageMarket.CreateStorageMiner, %s to Mpool", signed.Cid())
|
log.Infof("Pushed CreateMiner message: %s", signed.Cid())
|
||||||
log.Infof("Waiting for confirmation")
|
log.Infof("Waiting for confirmation")
|
||||||
|
|
||||||
mw, err := api.StateWaitMsg(ctx, signed.Cid(), build.MessageConfidence)
|
mw, err := api.StateWaitMsg(ctx, signed.Cid(), build.MessageConfidence)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return address.Undef, err
|
return address.Undef, xerrors.Errorf("waiting for createMiner message: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if mw.Receipt.ExitCode != 0 {
|
if mw.Receipt.ExitCode != 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user