Skip to content

Commit 30fa397

Browse files
authored
Merge pull request #473 from distractedm1nd/lazy-initGenesisChunks
Move initGenesisChunks call into GetGenesisChunks
2 parents 5e77f68 + 9550cf2 commit 30fa397

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

node/node.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ func (n *Node) OnStart() error {
215215
if err != nil {
216216
return fmt.Errorf("error while starting data availability layer client: %w", err)
217217
}
218-
err = n.initGenesisChunks()
219-
if err != nil {
220-
return fmt.Errorf("error while creating chunks of the genesis document: %w", err)
221-
}
222218
if n.conf.Aggregator {
223219
n.Logger.Info("working in aggregator mode", "block time", n.conf.BlockTime)
224220
go n.blockManager.AggregationLoop(n.ctx)
@@ -236,8 +232,12 @@ func (n *Node) GetGenesis() *tmtypes.GenesisDoc {
236232
}
237233

238234
// GetGenesisChunks returns chunked version of genesis.
239-
func (n *Node) GetGenesisChunks() []string {
240-
return n.genChunks
235+
func (n *Node) GetGenesisChunks() ([]string, error) {
236+
err := n.initGenesisChunks()
237+
if err != nil {
238+
return nil, err
239+
}
240+
return n.genChunks, err
241241
}
242242

243243
// OnStop is a part of Service interface.

rpc/client/client.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,10 @@ func (c *Client) Genesis(_ context.Context) (*ctypes.ResultGenesis, error) {
275275

276276
// GenesisChunked returns given chunk of genesis.
277277
func (c *Client) GenesisChunked(context context.Context, id uint) (*ctypes.ResultGenesisChunk, error) {
278-
genChunks := c.node.GetGenesisChunks()
278+
genChunks, err := c.node.GetGenesisChunks()
279+
if err != nil {
280+
return nil, fmt.Errorf("error while creating chunks of the genesis document: %w", err)
281+
}
279282
if genChunks == nil {
280283
return nil, fmt.Errorf("service configuration error, genesis chunks are not initialized")
281284
}

0 commit comments

Comments
 (0)