diff --git a/common/client/multi_node.go b/common/client/multi_node.go index a8868c883d0..0da3b89076b 100644 --- a/common/client/multi_node.go +++ b/common/client/multi_node.go @@ -11,13 +11,14 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" + "github.com/smartcontractkit/chainlink-relay/pkg/services" + "github.com/smartcontractkit/chainlink/v2/common/chains/client" feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types" "github.com/smartcontractkit/chainlink/v2/common/types" "github.com/smartcontractkit/chainlink/v2/core/assets" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -101,7 +102,7 @@ type multiNode[ HEAD types.Head[BLOCK_HASH], RPC_CLIENT RPC[CHAIN_ID, SEQ, ADDR, BLOCK_HASH, TX, TX_HASH, EVENT, EVENT_OPS, TX_RECEIPT, FEE, HEAD], ] struct { - utils.StartStopOnce + services.StateMachine nodes []Node[CHAIN_ID, HEAD, RPC_CLIENT] sendonlys []SendOnlyNode[CHAIN_ID, RPC_CLIENT] chainID CHAIN_ID diff --git a/common/client/node.go b/common/client/node.go index ef6773fa459..71b34452f02 100644 --- a/common/client/node.go +++ b/common/client/node.go @@ -11,6 +11,8 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" + "github.com/smartcontractkit/chainlink-relay/pkg/services" + "github.com/smartcontractkit/chainlink/v2/common/chains/client" "github.com/smartcontractkit/chainlink/v2/common/types" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -69,7 +71,7 @@ type node[ HEAD Head, RPC NodeClient[CHAIN_ID, HEAD], ] struct { - utils.StartStopOnce + services.StateMachine lfcLog logger.Logger name string id int32 diff --git a/common/client/send_only_node.go b/common/client/send_only_node.go index 30e71b96789..3b382b2dcb0 100644 --- a/common/client/send_only_node.go +++ b/common/client/send_only_node.go @@ -6,6 +6,8 @@ import ( "net/url" "sync" + "github.com/smartcontractkit/chainlink-relay/pkg/services" + "github.com/smartcontractkit/chainlink/v2/common/chains/client" "github.com/smartcontractkit/chainlink/v2/common/types" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -45,7 +47,7 @@ type sendOnlyNode[ CHAIN_ID types.ID, RPC sendOnlyClient[CHAIN_ID], ] struct { - utils.StartStopOnce + services.StateMachine stateMu sync.RWMutex // protects state* fields state nodeState diff --git a/common/client/send_only_node_lifecycle.go b/common/client/send_only_node_lifecycle.go index 9963d520e3b..0f663eab30e 100644 --- a/common/client/send_only_node_lifecycle.go +++ b/common/client/send_only_node_lifecycle.go @@ -51,17 +51,16 @@ func (s *sendOnlyNode[CHAIN_ID, RPC]) verifyLoop() { ) continue - } else { - ok := s.IfStarted(func() { - if changed := s.setState(nodeStateAlive); changed { - promPoolRPCNodeTransitionsToAlive.WithLabelValues(s.chainID.String(), s.name).Inc() - } - }) - if !ok { - return + } + ok := s.IfStarted(func() { + if changed := s.setState(nodeStateAlive); changed { + promPoolRPCNodeTransitionsToAlive.WithLabelValues(s.chainID.String(), s.name).Inc() } - s.log.Infow("Sendonly RPC Node is online", "nodeState", s.state) + }) + if !ok { return } + s.log.Infow("Sendonly RPC Node is online", "nodeState", s.state) + return } }