Skip to content

Commit

Permalink
Nit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dimriou committed Oct 17, 2023
1 parent 2b800b2 commit d2f9a4e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions common/client/multi_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ func (c *multiNode[CHAIN_ID, SEQ, ADDR, BLOCK_HASH, TX, TX_HASH, EVENT, EVENT_OP
}
}

c.activeMu.Lock()
if bestNode != c.activeNode {
c.activeMu.Lock()
c.activeNode = bestNode
c.activeMu.Unlock()
}
c.activeMu.Unlock()
}

func (c *multiNode[CHAIN_ID, SEQ, ADDR, BLOCK_HASH, TX, TX_HASH, EVENT, EVENT_OPS, TX_RECEIPT, FEE, HEAD, RPC_CLIENT]) checkLeaseLoop() {
Expand Down
5 changes: 3 additions & 2 deletions common/client/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

"github.com/smartcontractkit/chainlink/v2/common/chains/client"
"github.com/smartcontractkit/chainlink/v2/common/types"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/utils"
Expand Down Expand Up @@ -133,7 +134,7 @@ func NewNode[
}
n.nodeCtx, n.cancelNodeCtx = context.WithCancel(context.Background())
lggr = lggr.Named("Node").With(
"nodeTier", "primary",
"nodeTier", client.Primary.String(),
"nodeName", name,
"node", n.String(),
"chainID", chainID,
Expand All @@ -147,7 +148,7 @@ func NewNode[
}

func (n *node[CHAIN_ID, HEAD, RPC]) String() string {
s := fmt.Sprintf("(primary)%s:%s", n.name, n.ws.String())
s := fmt.Sprintf("(%s)%s:%s", client.Primary.String(), n.name, n.ws.String())
if n.http != nil {
s = s + fmt.Sprintf(":%s", n.http.String())
}
Expand Down
11 changes: 6 additions & 5 deletions common/client/send_only_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"net/url"
"sync"

"github.com/smartcontractkit/chainlink/v2/common/chains/client"
"github.com/smartcontractkit/chainlink/v2/common/types"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/utils"
)

type SendOnlyClient[
type sendOnlyClient[
CHAIN_ID types.ID,
] interface {
Close()
Expand All @@ -22,7 +23,7 @@ type SendOnlyClient[
// SendOnlyNode represents one node used as a sendonly
type SendOnlyNode[
CHAIN_ID types.ID,
RPC SendOnlyClient[CHAIN_ID],
RPC sendOnlyClient[CHAIN_ID],
] interface {
// Start may attempt to connect to the node, but should only return error for misconfiguration - never for temporary errors.
Start(context.Context) error
Expand All @@ -42,7 +43,7 @@ type SendOnlyNode[
// It must use an http(s) url
type sendOnlyNode[
CHAIN_ID types.ID,
RPC SendOnlyClient[CHAIN_ID],
RPC sendOnlyClient[CHAIN_ID],
] struct {
utils.StartStopOnce

Expand All @@ -61,7 +62,7 @@ type sendOnlyNode[
// NewSendOnlyNode returns a new sendonly node
func NewSendOnlyNode[
CHAIN_ID types.ID,
RPC SendOnlyClient[CHAIN_ID],
RPC sendOnlyClient[CHAIN_ID],
](
lggr logger.Logger,
httpuri url.URL,
Expand Down Expand Up @@ -156,7 +157,7 @@ func (s *sendOnlyNode[CHAIN_ID, RPC]) RPC() RPC {
}

func (s *sendOnlyNode[CHAIN_ID, RPC]) String() string {
return fmt.Sprintf("(secondary)%s:%s", s.name, s.uri.Redacted())
return fmt.Sprintf("(%s)%s:%s", client.Secondary.String(), s.name, s.uri.Redacted())
}

func (s *sendOnlyNode[CHAIN_ID, RPC]) setState(state nodeState) (changed bool) {
Expand Down

0 comments on commit d2f9a4e

Please sign in to comment.