Skip to content

Commit

Permalink
[BCF-2365] Combine providers into one constructor (#164)
Browse files Browse the repository at this point in the history
- Remove NewMercuryProvider, NewMedianProvider, NewFunctionsProvider from
the Relayer interface. This is to allow transparent proxying of provider
calls from reporting plugin loopps to relayer loopps, without the core
node needing to be aware of the types.
- From now on, creating a provider should happen via NewPluginProvider,
setting RelayArgs.ProviderType as appropriate.
- RelayArgs.ProviderType maps to the OCR2PluginType, which this commit
relocates from the core node to here.
- LOOPP Relayer implementations can still implement
NewMercuryProvider/NewMedianProvider/.... The RelayerServer will check
whether the underlying implementation contains these methods and will
redirect the call to this more specialized function if that is the case.
- For interoperability with legacy code in the core node which needs to be
aware of the product providers, the RelayerClient will instantiate a
provider of the right type inside NewPluginProvider, thus allowing
calling code to typecast to the right underlying provider type.
  • Loading branch information
cedric-cordenier authored Sep 8, 2023
1 parent da01915 commit 16ce8fa
Show file tree
Hide file tree
Showing 16 changed files with 900 additions and 901 deletions.
File renamed without changes.
16 changes: 5 additions & 11 deletions pkg/loop/internal/median.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,28 +170,22 @@ var (
)

type medianProviderClient struct {
*configProviderClient
contractTransmitter libocr.ContractTransmitter
reportCodec median.ReportCodec
medianContract median.MedianContract
onchainConfigCodec median.OnchainConfigCodec
*pluginProviderClient
reportCodec median.ReportCodec
medianContract median.MedianContract
onchainConfigCodec median.OnchainConfigCodec
}

func (m *medianProviderClient) ClientConn() grpc.ClientConnInterface { return m.cc }

func newMedianProviderClient(b *brokerExt, cc grpc.ClientConnInterface) *medianProviderClient {
m := &medianProviderClient{configProviderClient: newConfigProviderClient(b.withName("MedianProviderClient"), cc)}
m.contractTransmitter = &contractTransmitterClient{b, pb.NewContractTransmitterClient(m.cc)}
m := &medianProviderClient{pluginProviderClient: newPluginProviderClient(b.withName("MedianProviderClient"), cc)}
m.reportCodec = &reportCodecClient{b, pb.NewReportCodecClient(m.cc)}
m.medianContract = &medianContractClient{pb.NewMedianContractClient(m.cc)}
m.onchainConfigCodec = &onchainConfigCodecClient{b, pb.NewOnchainConfigCodecClient(m.cc)}
return m
}

func (m *medianProviderClient) ContractTransmitter() libocr.ContractTransmitter {
return m.contractTransmitter
}

func (m *medianProviderClient) ReportCodec() median.ReportCodec {
return m.reportCodec
}
Expand Down
Loading

0 comments on commit 16ce8fa

Please sign in to comment.