seed: Set valid PeerIDs
This commit is contained in:
parent
cdbf79fff5
commit
769cf43b52
@ -13,6 +13,8 @@ import (
|
|||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
|
ic "github.com/libp2p/go-libp2p-core/crypto"
|
||||||
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@ -117,6 +119,21 @@ func PreSeal(maddr address.Address, pt abi.RegisteredProof, offset abi.SectorNum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pid peer.ID
|
||||||
|
{
|
||||||
|
log.Warn("PeerID not specified, generating dummy")
|
||||||
|
p, _, err := ic.GenerateEd25519Key(rand.Reader)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
pid, err = peer.IDFromPrivateKey(p)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
miner := &genesis.Miner{
|
miner := &genesis.Miner{
|
||||||
Owner: minerAddr.Address,
|
Owner: minerAddr.Address,
|
||||||
Worker: minerAddr.Address,
|
Worker: minerAddr.Address,
|
||||||
@ -124,6 +141,7 @@ func PreSeal(maddr address.Address, pt abi.RegisteredProof, offset abi.SectorNum
|
|||||||
PowerBalance: big.Zero(),
|
PowerBalance: big.Zero(),
|
||||||
SectorSize: ssize,
|
SectorSize: ssize,
|
||||||
Sectors: sealedSectors,
|
Sectors: sealedSectors,
|
||||||
|
PeerId: pid,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := createDeals(miner, minerAddr, maddr, ssize); err != nil {
|
if err := createDeals(miner, minerAddr, maddr, ssize); err != nil {
|
||||||
|
@ -28,7 +28,7 @@ type PreSeal struct {
|
|||||||
type Miner struct {
|
type Miner struct {
|
||||||
Owner address.Address
|
Owner address.Address
|
||||||
Worker address.Address
|
Worker address.Address
|
||||||
PeerId peer.ID `json:",omitempty"`
|
PeerId peer.ID
|
||||||
|
|
||||||
MarketBalance abi.TokenAmount
|
MarketBalance abi.TokenAmount
|
||||||
PowerBalance abi.TokenAmount
|
PowerBalance abi.TokenAmount
|
||||||
|
Loading…
Reference in New Issue
Block a user