seed: Set valid PeerIDs

This commit is contained in:
Łukasz Magiera 2020-04-17 18:22:17 +02:00
parent cdbf79fff5
commit 769cf43b52
2 changed files with 19 additions and 1 deletions

View File

@ -13,6 +13,8 @@ import (
"github.com/google/uuid"
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"
"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{
Owner: minerAddr.Address,
Worker: minerAddr.Address,
@ -124,6 +141,7 @@ func PreSeal(maddr address.Address, pt abi.RegisteredProof, offset abi.SectorNum
PowerBalance: big.Zero(),
SectorSize: ssize,
Sectors: sealedSectors,
PeerId: pid,
}
if err := createDeals(miner, minerAddr, maddr, ssize); err != nil {

View File

@ -28,7 +28,7 @@ type PreSeal struct {
type Miner struct {
Owner address.Address
Worker address.Address
PeerId peer.ID `json:",omitempty"`
PeerId peer.ID
MarketBalance abi.TokenAmount
PowerBalance abi.TokenAmount