Skip to content

Commit

Permalink
simplify types (#8744)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Mar 17, 2023
1 parent 2bc5c38 commit 2206d7c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
4 changes: 2 additions & 2 deletions core/chains/evm/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type chain struct {
id *big.Int
cfg evmconfig.ChainScopedConfig
client evmclient.Client
txm *evmTxm
txm txmgr.TxManager
logger logger.Logger
headBroadcaster httypes.HeadBroadcaster
headTracker httypes.HeadTracker
Expand Down Expand Up @@ -254,7 +254,7 @@ func (c *chain) Config() evmconfig.ChainScopedConfig { return c.cfg }
func (c *chain) LogBroadcaster() log.Broadcaster { return c.logBroadcaster }
func (c *chain) LogPoller() logpoller.LogPoller { return c.logPoller }
func (c *chain) HeadBroadcaster() httypes.HeadBroadcaster { return c.headBroadcaster }
func (c *chain) TxManager() txmgr.TxManager { return c.txm.TxManager }
func (c *chain) TxManager() txmgr.TxManager { return c.txm }
func (c *chain) HeadTracker() httypes.HeadTracker { return c.headTracker }
func (c *chain) Logger() logger.Logger { return c.logger }
func (c *chain) BalanceMonitor() monitor.BalanceMonitor { return c.balanceMonitor }
Expand Down
19 changes: 2 additions & 17 deletions core/chains/evm/evm_txm.go
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
package evm

import (
"context"
"fmt"

"github.com/smartcontractkit/sqlx"

evmclient "github.com/smartcontractkit/chainlink/core/chains/evm/client"
evmconfig "github.com/smartcontractkit/chainlink/core/chains/evm/config"
httypes "github.com/smartcontractkit/chainlink/core/chains/evm/headtracker/types"
"github.com/smartcontractkit/chainlink/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/core/chains/evm/txmgr"
evmtypes "github.com/smartcontractkit/chainlink/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/core/logger"
)

var _ httypes.HeadTrackable = &evmTxm{}

// evmTxm is an evm wrapper over the generic TxManager interface
type evmTxm struct {
httypes.HeadTrackable
txmgr.TxManager
}

func (e evmTxm) OnNewLongestChain(ctx context.Context, head *evmtypes.Head) {
e.TxManager.OnNewLongestChain(ctx, head)
}

func newEvmTxm(
db *sqlx.DB,
cfg evmconfig.ChainScopedConfig,
client evmclient.Client,
lggr logger.Logger,
logPoller logpoller.LogPoller,
opts ChainSetOpts,
) *evmTxm {
) txmgr.TxManager {
chainID := cfg.ChainID()
var txm txmgr.TxManager
if !cfg.EVMRPCEnabled() {
Expand All @@ -45,5 +30,5 @@ func newEvmTxm(
} else {
txm = opts.GenTxManager(chainID)
}
return &evmTxm{TxManager: txm}
return txm
}
5 changes: 2 additions & 3 deletions core/chains/evm/headtracker/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/ethereum/go-ethereum/common"

"github.com/smartcontractkit/chainlink/common/txmgr/types"
evmtypes "github.com/smartcontractkit/chainlink/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/core/services"
)
Expand Down Expand Up @@ -40,9 +41,7 @@ type HeadTracker interface {
// after being subscribed to HeadBroadcaster
//
//go:generate mockery --quiet --name HeadTrackable --output ../mocks/ --case=underscore
type HeadTrackable interface {
OnNewLongestChain(ctx context.Context, head *evmtypes.Head)
}
type HeadTrackable = types.HeadTrackable[*evmtypes.Head]

type HeadBroadcasterRegistry interface {
Subscribe(callback HeadTrackable) (currentLongestChain *evmtypes.Head, unsubscribe func())
Expand Down

0 comments on commit 2206d7c

Please sign in to comment.