Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
apply genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
okislitsin committed Aug 26, 2019
1 parent 69dbc10 commit 06517a2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/cmd/main.go
Expand Up @@ -144,22 +144,30 @@ func actionLachesis(ctx *cli.Context) error {
return fmt.Errorf("invalid command: %q", args[0])
}

node := makeFullNode(ctx)
node, err := makeFullNode(ctx)
if err != nil {
return err
}
defer node.Close()

utils.StartNode(node)
node.Wait()
return nil
}

func makeFullNode(ctx *cli.Context) *node.Node {
func makeFullNode(ctx *cli.Context) (*node.Node, error) {
nodeCfg := makeNodeConfig(ctx)
networkCfg := makeLachesisConfig(ctx)
gossipCfg := makeGossipConfig(ctx, networkCfg)

makeDb := dbProducer(nodeCfg.DataDir)
gdb, cdb := makeStorages(makeDb)

err := cdb.ApplyGenesis(&networkCfg.Genesis)
if err != nil {
return nil, err
}

// Create consensus.
engine := poset.New(cdb, gdb)

Expand All @@ -181,5 +189,5 @@ func makeFullNode(ctx *cli.Context) *node.Node {
log.Fatalf("Failed to register service: %v", err)
}

return stack
return stack, nil
}

0 comments on commit 06517a2

Please sign in to comment.