Skip to content

Commit

Permalink
Compatibility with chainlink
Browse files Browse the repository at this point in the history
  • Loading branch information
winder committed Dec 18, 2024
1 parent b30f29b commit 4b15bd3
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 10 deletions.
94 changes: 94 additions & 0 deletions mocks/pkg/contractreader/extended.go

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

21 changes: 13 additions & 8 deletions pkg/contractreader/extended.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ var (

// Extended version of a ContractReader.
type Extended interface {
// Unbind is included for compatibility with ContractReader
Unbind(ctx context.Context, bindings []types.BoundContract) error
// HealthReport is included for compatibility with ContractReader
HealthReport() map[string]error

Bind(ctx context.Context, bindings []types.BoundContract) error

GetBindings(contractName string) []ExtendedBoundContract
Expand Down Expand Up @@ -278,19 +283,19 @@ func (e *extendedContractReader) bindingExists(b types.BoundContract) bool {
}

func (e *extendedContractReader) hasFinalityViolation() bool {
if e.reader == nil {
return false
}

if _, ok := e.reader.(Extended); ok {
panic("bad news")
}

report := e.reader.HealthReport()
return services.ContainsError(
report,
clcommontypes.ErrFinalityViolated)
}

func (e *extendedContractReader) Unbind(ctx context.Context, bindings []types.BoundContract) error {
return e.reader.Unbind(ctx, bindings)
}

func (e *extendedContractReader) HealthReport() map[string]error {
return e.reader.HealthReport()
}

// Interface compliance check
var _ Extended = (*extendedContractReader)(nil)
4 changes: 2 additions & 2 deletions pkg/reader/rmn_home.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type rmnHomePoller struct {
stopCh services.StopChan
sync services.StateMachine
mutex *sync.RWMutex
contractReader contractreader.Extended
contractReader contractreader.ContractReaderFacade
rmnHomeBoundContract types.BoundContract
lggr logger.Logger
rmnHomeState rmnHomeState
Expand All @@ -70,7 +70,7 @@ type rmnHomePoller struct {
}

func NewRMNHomePoller(
contractReader contractreader.Extended,
contractReader contractreader.ContractReaderFacade,
rmnHomeBoundContract types.BoundContract,
lggr logger.Logger,
pollingInterval time.Duration,
Expand Down

0 comments on commit 4b15bd3

Please sign in to comment.