Skip to content

Commit

Permalink
Merge pull request cosmos#473 from distractedm1nd/lazy-initGenesisChunks
Browse files Browse the repository at this point in the history
Move initGenesisChunks call into GetGenesisChunks
  • Loading branch information
tzdybal authored Jul 28, 2022
2 parents 5e77f68 + 9550cf2 commit 30fa397
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 6 additions & 6 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ func (n *Node) OnStart() error {
if err != nil {
return fmt.Errorf("error while starting data availability layer client: %w", err)
}
err = n.initGenesisChunks()
if err != nil {
return fmt.Errorf("error while creating chunks of the genesis document: %w", err)
}
if n.conf.Aggregator {
n.Logger.Info("working in aggregator mode", "block time", n.conf.BlockTime)
go n.blockManager.AggregationLoop(n.ctx)
Expand All @@ -236,8 +232,12 @@ func (n *Node) GetGenesis() *tmtypes.GenesisDoc {
}

// GetGenesisChunks returns chunked version of genesis.
func (n *Node) GetGenesisChunks() []string {
return n.genChunks
func (n *Node) GetGenesisChunks() ([]string, error) {
err := n.initGenesisChunks()
if err != nil {
return nil, err
}
return n.genChunks, err
}

// OnStop is a part of Service interface.
Expand Down
5 changes: 4 additions & 1 deletion rpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ func (c *Client) Genesis(_ context.Context) (*ctypes.ResultGenesis, error) {

// GenesisChunked returns given chunk of genesis.
func (c *Client) GenesisChunked(context context.Context, id uint) (*ctypes.ResultGenesisChunk, error) {
genChunks := c.node.GetGenesisChunks()
genChunks, err := c.node.GetGenesisChunks()
if err != nil {
return nil, fmt.Errorf("error while creating chunks of the genesis document: %w", err)
}
if genChunks == nil {
return nil, fmt.Errorf("service configuration error, genesis chunks are not initialized")
}
Expand Down

0 comments on commit 30fa397

Please sign in to comment.