Skip to content

Commit

Permalink
Extract chain reads from ChainService relayer into Chain Reader
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Oct 30, 2024
1 parent c5c856e commit 34d7a88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions pkg/loop/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type OCR3CapabilityProvider interface {
// Relayer is like types.Relayer, but with a dynamic NewPluginProvider method.
type Relayer interface {
types.ChainService
types.ChainReader

// NewChainWriter returns a new ChainWriter.
// The format of config depends on the implementation.
Expand Down
21 changes: 11 additions & 10 deletions pkg/types/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,34 @@ type NodeStatus struct {
State string
}

// ChainService is a sub-interface that encapsulates the explicit interactions with a chain, rather than through a provider.
type ChainService interface {
Service

type ChainReader interface {
// NewContractReader returns a new ContractReader.
// The format of contractReaderConfig depends on the implementation.
NewContractReader(ctx context.Context, contractReaderConfig []byte) (ContractReader, error)
// LatestHead returns the latest head for the underlying chain.
LatestHead(ctx context.Context) (Head, error)
// GetChainStatus returns the ChainStatus for this Relayer.
GetChainStatus(ctx context.Context) (ChainStatus, error)
// ListNodeStatuses returns the status of RPC nodes.
ListNodeStatuses(ctx context.Context, pageSize int32, pageToken string) (stats []NodeStatus, nextPageToken string, total int, err error)
}

// ChainService is a sub-interface that encapsulates the explicit interactions with a chain, rather than through a provider.
type ChainService interface {
Service
// Transact submits a transaction to transfer tokens.
// If balanceCheck is true, the balance will be checked before submitting.
Transact(ctx context.Context, from, to string, amount *big.Int, balanceCheck bool) error
}

// Relayer extends ChainService with providers for each product.
// Relayer extends ChainService and ChainReader with providers for each product.
type Relayer interface {
ChainService

ChainReader
// NewChainWriter returns a new ChainWriter.
// The format of config depends on the implementation.
NewChainWriter(ctx context.Context, config []byte) (ChainWriter, error)

// NewContractReader returns a new ContractReader.
// The format of contractReaderConfig depends on the implementation.
NewContractReader(ctx context.Context, contractReaderConfig []byte) (ContractReader, error)

NewConfigProvider(ctx context.Context, rargs RelayArgs) (ConfigProvider, error)

NewMedianProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (MedianProvider, error)
Expand Down

0 comments on commit 34d7a88

Please sign in to comment.