Skip to content

Commit

Permalink
Add logs and handle disabled chain reader when median loop is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Nov 26, 2023
1 parent 9f831e6 commit 4e70656
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/services/ocr2/plugins/median/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,24 @@ func NewMedianServices(ctx context.Context,
CreatedAt: time.Now(),
}, lggr)

if medianProvider.ChainReader() != nil {
medianPluginCmd := env.MedianPluginCmd.Get()
medianLoopEnabled := medianPluginCmd != ""

// TODO BCF-2821 handle this properly as this blocks Solana dev
if !medianLoopEnabled && medianProvider.ChainReader() != nil {
lggr.Info("Chain Reader enabled")
medianProvider = medianProviderWrapper{
medianProvider, // attach newer MedianContract which uses ChainReader
newMedianContract(provider.ChainReader(), common.HexToAddress(spec.ContractID)),
}
} else {
lggr.Info("Chain Reader disabled")
}

if cmdName := env.MedianPluginCmd.Get(); cmdName != "" {

if medianLoopEnabled {
// use unique logger names so we can use it to register a loop
medianLggr := lggr.Named("Median").Named(spec.ContractID).Named(spec.GetID())
cmdFn, telem, err2 := cfg.RegisterLOOP(medianLggr.Name(), cmdName)
cmdFn, telem, err2 := cfg.RegisterLOOP(medianLggr.Name(), medianPluginCmd)
if err2 != nil {
err = fmt.Errorf("failed to register loop: %w", err2)
abort()
Expand Down

0 comments on commit 4e70656

Please sign in to comment.