Skip to content

Commit

Permalink
Merge pull request #81 from blinklabs-io/fix/config-override-intercept
Browse files Browse the repository at this point in the history
fix: don't overwrite provided script/intercept values with defaults
  • Loading branch information
agaffney authored Nov 21, 2023
2 parents fb53e53 + ff26048 commit 4063f4b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,19 @@ func Load(configFile string) (*Config, error) {
return nil, fmt.Errorf("error processing environment: %s", err)
}
// Provide default script address for named network
if scriptAddress, ok := networkScriptAddresses[globalConfig.Indexer.Network]; ok {
globalConfig.Indexer.ScriptAddress = scriptAddress
} else {
return nil, fmt.Errorf("no built-in script address for specified network, please provide one")
if globalConfig.Indexer.ScriptAddress == "" {
if scriptAddress, ok := networkScriptAddresses[globalConfig.Indexer.Network]; ok {
globalConfig.Indexer.ScriptAddress = scriptAddress
} else {
return nil, fmt.Errorf("no built-in script address for specified network, please provide one")
}
}
// Provide default intercept point for named network
if interceptPoint, ok := networkInterceptPoints[globalConfig.Indexer.Network]; ok {
globalConfig.Indexer.InterceptHash = interceptPoint.Hash
globalConfig.Indexer.InterceptSlot = interceptPoint.Slot
if globalConfig.Indexer.InterceptSlot == 0 || globalConfig.Indexer.InterceptHash == "" {
if interceptPoint, ok := networkInterceptPoints[globalConfig.Indexer.Network]; ok {
globalConfig.Indexer.InterceptHash = interceptPoint.Hash
globalConfig.Indexer.InterceptSlot = interceptPoint.Slot
}
}
return globalConfig, nil
}
Expand Down

0 comments on commit 4063f4b

Please sign in to comment.