Skip to content

Commit

Permalink
Error when chain id is missing from default block chain info.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemire committed Sep 9, 2024
1 parent 173dbe7 commit 5eb1a01
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/config/blockchain_info.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package config

import "time"
import (
"context"
"time"

"github.com/river-build/river/core/node/dlog"
)

type BlockchainInfo struct {
ChainId uint64
Expand All @@ -10,11 +15,18 @@ type BlockchainInfo struct {
Blocktime time.Duration
}

func GetEtherBasedBlockchains(chains []uint64, defaultBlockchainInfo map[uint64]BlockchainInfo) []uint64 {
func GetEtherBasedBlockchains(
ctx context.Context,
chains []uint64,
defaultBlockchainInfo map[uint64]BlockchainInfo,
) []uint64 {
log := dlog.FromCtx(ctx)
etherBasedChains := make([]uint64, 0, len(chains))
for _, chainId := range chains {
if info, ok := defaultBlockchainInfo[chainId]; ok && info.IsEtherBased {
etherBasedChains = append(etherBasedChains, chainId)
} else if !ok {
log.Error("Missing BlockchainInfo for chain", "chainId", chainId)
}
}
return etherBasedChains
Expand Down
1 change: 1 addition & 0 deletions core/xchain/entitlement/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func NewEvaluatorFromConfigWithBlockchainInfo(
"operation",
),
ethChainIds: config.GetEtherBasedBlockchains(
ctx,
cfg.XChainBlockchains,
blockChainInfo,
),
Expand Down

0 comments on commit 5eb1a01

Please sign in to comment.