Skip to content

Commit

Permalink
Merge branch 'master' into cl/relay-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower authored Dec 13, 2023
2 parents 756f616 + aa42d6c commit 4b66827
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions broadcastclients/broadcastclients.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type BroadcastClients struct {
primaryClients []*broadcastclient.BroadcastClient
secondaryClients []*broadcastclient.BroadcastClient
secondaryURL []string
makeClient func(string, *Router) (*broadcastclient.BroadcastClient, error)

primaryRouter *Router
secondaryRouter *Router
Expand All @@ -51,8 +52,6 @@ type BroadcastClients struct {
connected int32
}

var makeClient func(string, *Router) (*broadcastclient.BroadcastClient, error)

func NewBroadcastClients(
configFetcher broadcastclient.ConfigFetcher,
l2ChainId uint64,
Expand Down Expand Up @@ -81,7 +80,7 @@ func NewBroadcastClients(
secondaryClients: make([]*broadcastclient.BroadcastClient, 0, len(config.SecondaryURL)),
secondaryURL: config.SecondaryURL,
}
makeClient = func(url string, router *Router) (*broadcastclient.BroadcastClient, error) {
clients.makeClient = func(url string, router *Router) (*broadcastclient.BroadcastClient, error) {
return broadcastclient.NewBroadcastClient(
configFetcher,
url,
Expand All @@ -97,7 +96,7 @@ func NewBroadcastClients(

var lastClientErr error
for _, address := range config.URL {
client, err := makeClient(address, clients.primaryRouter)
client, err := clients.makeClient(address, clients.primaryRouter)
if err != nil {
lastClientErr = err
log.Warn("init broadcast client failed", "address", address)
Expand Down Expand Up @@ -243,7 +242,7 @@ func (bcs *BroadcastClients) startSecondaryFeed(ctx context.Context) {
pos := len(bcs.secondaryClients)
if pos < len(bcs.secondaryURL) {
url := bcs.secondaryURL[pos]
client, err := makeClient(url, bcs.secondaryRouter)
client, err := bcs.makeClient(url, bcs.secondaryRouter)
if err != nil {
log.Warn("init broadcast secondary client failed", "address", url)
bcs.secondaryURL = append(bcs.secondaryURL[:pos], bcs.secondaryURL[pos+1:]...)
Expand Down

0 comments on commit 4b66827

Please sign in to comment.