lotus/cmd/lotus-seed/main.go

95 lines
1.9 KiB
Go
Raw Normal View History

2019-11-25 04:45:13 +00:00
package main
import (
"os"
logging "github.com/ipfs/go-log"
"github.com/mitchellh/go-homedir"
"gopkg.in/urfave/cli.v2"
2019-11-26 13:52:59 +00:00
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/address"
2019-11-27 14:18:51 +00:00
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
2019-11-25 04:45:13 +00:00
)
var log = logging.Logger("lotus-seed")
func main() {
logging.SetLogLevel("*", "INFO")
log.Info("Starting seed")
local := []*cli.Command{
preSealCmd,
}
app := &cli.App{
Name: "lotus-seed",
Usage: "Seal sectors for genesis miner",
Version: build.Version,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "sectorbuilder-dir",
Value: "~/.genesis-sectors",
},
},
Commands: local,
}
if err := app.Run(os.Args); err != nil {
log.Warn(err)
return
}
}
var preSealCmd = &cli.Command{
Name: "pre-seal",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "miner-addr",
Value: "t0101",
Usage: "specify the future address of your miner",
},
&cli.Uint64Flag{
Name: "sector-size",
Value: build.SectorSizes[0],
2019-11-25 04:45:13 +00:00
Usage: "specify size of sectors to pre-seal",
},
&cli.StringFlag{
Name: "ticket-preimage",
Value: "lotus is fire",
Usage: "set the ticket preimage for sealing randomness",
},
2019-11-30 23:17:50 +00:00
&cli.IntFlag{
2019-11-25 04:45:13 +00:00
Name: "num-sectors",
Value: 1,
Usage: "select number of sectors to pre-seal",
},
&cli.Uint64Flag{
Name: "sector-offset",
Value: 0,
Usage: "select number of sectors to pre-seal",
},
2019-11-25 04:45:13 +00:00
},
Action: func(c *cli.Context) error {
sdir := c.String("sectorbuilder-dir")
sbroot, err := homedir.Expand(sdir)
if err != nil {
return err
}
maddr, err := address.NewFromString(c.String("miner-addr"))
if err != nil {
return err
}
gm, err := seed.PreSeal(maddr, c.Uint64("sector-size"), c.Uint64("sector-offset"), c.Int("num-sectors"), sbroot, []byte(c.String("ticket-preimage")))
2019-11-29 03:38:18 +00:00
if err != nil {
return err
}
return seed.WriteGenesisMiner(maddr, sbroot, gm)
2019-11-25 04:45:13 +00:00
},
}