Skip to content

Commit

Permalink
Fix: creation database before creation node wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Sep 11, 2023
1 parent 012c7ae commit fb6933b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/indexer/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewBlockchainIndexer(ctx context.Context, cfg config.Config, network string
networkType,
config.WithConfigCopy(cfg),
config.WithStorage(cfg.Storage, "indexer", 10, cfg.Indexer.Connections.Open, cfg.Indexer.Connections.Idle, true),
config.WithWaitRPC(cfg.RPC),
config.WithRPC(cfg.RPC),
)
logger.Info().Str("network", internalCtx.Network.String()).Msg("Creating indexer object...")

Expand Down Expand Up @@ -129,6 +129,15 @@ func (bi *BlockchainIndexer) init(ctx context.Context, db *core.Postgres) error

bi.currentProtocol = currentProtocol
logger.Info().Str("network", bi.Network.String()).Msgf("Current network protocol: %s", currentProtocol.Hash)

for {
if _, err := bi.Context.RPC.GetLevel(ctx); err == nil {
break
}
logger.Warning().Str("network", bi.Network.String()).Msg("waiting node rpc...")
time.Sleep(time.Second * 15)
}

return nil
}

Expand Down
1 change: 1 addition & 0 deletions internal/noderpc/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ type INode interface {
GetCounter(context.Context, string) (int64, error)
GetBigMapType(ctx context.Context, ptr, level int64) (BigMap, error)
GetBlockMetadata(ctx context.Context, level int64) (metadata Metadata, err error)
GetLevel(ctx context.Context) (int64, error)
}
39 changes: 39 additions & 0 deletions internal/noderpc/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fb6933b

Please sign in to comment.