Skip to content

Commit

Permalink
Deprecate StartStopOnce
Browse files Browse the repository at this point in the history
  • Loading branch information
dimriou committed Nov 1, 2023
1 parent 679799e commit 25f09f7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
5 changes: 3 additions & 2 deletions common/client/multi_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion common/client/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion common/client/send_only_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
17 changes: 8 additions & 9 deletions common/client/send_only_node_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 25f09f7

Please sign in to comment.