Merge pull request #1338 from filecoin-project/fix/miner-init
fix storage miner init logic
This commit is contained in:
commit
ea0dcdcfac
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
@ -439,7 +440,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
|||||||
} else {
|
} else {
|
||||||
a, err := createStorageMiner(ctx, api, peerid, cctx)
|
a, err := createStorageMiner(ctx, api, peerid, cctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return xerrors.Errorf("creating miner failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = a
|
addr = a
|
||||||
@ -550,6 +551,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
params, err := actors.SerializeParams(&power.CreateMinerParams{
|
params, err := actors.SerializeParams(&power.CreateMinerParams{
|
||||||
|
Owner: owner,
|
||||||
Worker: worker,
|
Worker: worker,
|
||||||
SectorSize: abi.SectorSize(ssize),
|
SectorSize: abi.SectorSize(ssize),
|
||||||
Peer: peerid,
|
Peer: peerid,
|
||||||
@ -587,11 +589,11 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
|||||||
return address.Undef, xerrors.Errorf("create storage miner failed: exit code %d", mw.Receipt.ExitCode)
|
return address.Undef, xerrors.Errorf("create storage miner failed: exit code %d", mw.Receipt.ExitCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, err = address.NewFromBytes(mw.Receipt.Return)
|
var retval power.CreateMinerReturn
|
||||||
if err != nil {
|
if err := retval.UnmarshalCBOR(bytes.NewReader(mw.Receipt.Return)); err != nil {
|
||||||
return address.Undef, err
|
return address.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("New storage miners address is: %s", addr)
|
log.Infof("New storage miners address is: %s (%s)", retval.IDAddress, retval.RobustAddress)
|
||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user