From c4e2208c7a2719e72c7af10514ec38661bbd1a1a Mon Sep 17 00:00:00 2001 From: Will Winder Date: Wed, 18 Dec 2024 14:55:47 -0500 Subject: [PATCH] Compatibility with chainlink --- commit/factory.go | 4 ++-- execute/factory.go | 4 ++-- internal/reader/home_chain.go | 4 ++-- pkg/contractreader/observed.go | 10 +++++----- pkg/reader/home_chain.go | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/commit/factory.go b/commit/factory.go index 01b41e3d..8e35e371 100644 --- a/commit/factory.go +++ b/commit/factory.go @@ -162,8 +162,8 @@ func (p *PluginFactory) NewReportingPlugin(ctx context.Context, config ocr3types if err1 != nil { return nil, ocr3types.ReportingPluginInfo{}, fmt.Errorf("failed to get chain id from selector: %w", err1) } - readers[chain] = contractreader.NewObserverReader( - contractreader.NewExtendedContractReader(cr), lggr, chainID) + readers[chain] = contractreader.NewExtendedContractReader( + contractreader.NewObserverReader(cr, lggr, chainID)) } // Bind the RMNHome contract diff --git a/execute/factory.go b/execute/factory.go index 97fd6123..376520fd 100644 --- a/execute/factory.go +++ b/execute/factory.go @@ -156,8 +156,8 @@ func (p PluginFactory) NewReportingPlugin( if err1 != nil { return nil, ocr3types.ReportingPluginInfo{}, fmt.Errorf("failed to get chain id from selector: %w", err1) } - readers[chain] = contractreader.NewObserverReader( - contractreader.NewExtendedContractReader(cr), lggr, chainID) + readers[chain] = contractreader.NewExtendedContractReader( + contractreader.NewObserverReader(cr, lggr, chainID)) } ccipReader := readerpkg.NewCCIPChainReader( diff --git a/internal/reader/home_chain.go b/internal/reader/home_chain.go index 0992ebda..86db229b 100644 --- a/internal/reader/home_chain.go +++ b/internal/reader/home_chain.go @@ -55,7 +55,7 @@ type homeChainPoller struct { wg sync.WaitGroup stopCh services.StopChan sync services.StateMachine - homeChainReader contractreader.Extended + homeChainReader contractreader.ContractReaderFacade lggr logger.Logger mutex *sync.RWMutex state state @@ -68,7 +68,7 @@ type homeChainPoller struct { const MaxFailedPolls = 10 func NewHomeChainConfigPoller( - homeChainReader contractreader.Extended, + homeChainReader contractreader.ContractReaderFacade, lggr logger.Logger, pollingInterval time.Duration, ccipConfigBoundContract types.BoundContract, diff --git a/pkg/contractreader/observed.go b/pkg/contractreader/observed.go index 2b31f11b..699f5e1d 100644 --- a/pkg/contractreader/observed.go +++ b/pkg/contractreader/observed.go @@ -63,7 +63,7 @@ var ( ) type Observed struct { - Extended + ContractReaderFacade lggr logger.Logger chainID string @@ -75,12 +75,12 @@ type Observed struct { } func NewObserverReader( - cr Extended, + cr ContractReaderFacade, lggr logger.Logger, chainID string, ) *Observed { return &Observed{ - Extended: cr, + ContractReaderFacade: cr, lggr: lggr, chainID: chainID, directRequestsDurations: CrDirectRequestsDurations, @@ -97,7 +97,7 @@ func (o *Observed) GetLatestValue( params, returnVal any, ) error { start := time.Now() - err := o.Extended.GetLatestValue(ctx, readIdentifier, confidenceLevel, params, returnVal) + err := o.ContractReaderFacade.GetLatestValue(ctx, readIdentifier, confidenceLevel, params, returnVal) duration := time.Since(start) contract, function := unpackReadIdentifier(readIdentifier) @@ -121,7 +121,7 @@ func (o *Observed) BatchGetLatestValues( request types.BatchGetLatestValuesRequest, ) (types.BatchGetLatestValuesResult, error) { start := time.Now() - result, err := o.Extended.BatchGetLatestValues(ctx, request) + result, err := o.ContractReaderFacade.BatchGetLatestValues(ctx, request) duration := time.Since(start) o.batchRequestsDurations. diff --git a/pkg/reader/home_chain.go b/pkg/reader/home_chain.go index e57de89c..b3eacc4b 100644 --- a/pkg/reader/home_chain.go +++ b/pkg/reader/home_chain.go @@ -25,7 +25,7 @@ type OCR3Config = reader_internal.OCR3Config type OCR3Node = reader_internal.OCR3Node func NewObservedHomeChainReader( - homeChainReader contractreader.Extended, + homeChainReader contractreader.ContractReaderFacade, lggr logger.Logger, pollingInterval time.Duration, ccipConfigBoundContract types.BoundContract,