Skip to content

Commit

Permalink
ir: Fix neo-go connection loss message
Browse files Browse the repository at this point in the history
It printed "mainnet" for every connection loss before. Pass parameters as a
copy, not as a pointer. It has been that way since the beginning of time, no
one knows why.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
notimetoname committed Jun 29, 2023
1 parent 464c472 commit 8bbbec0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/innerring/innerring.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func New(ctx context.Context, log *logger.Logger, cfg *viper.Viper, errChan chan
log.Warn("can't get last processed side chain block number", zap.String("error", err.Error()))
}

morphChain := &chainParams{
morphChain := chainParams{
log: log,
cfg: cfg,
name: morphPrefix,
Expand Down Expand Up @@ -953,7 +953,7 @@ func New(ctx context.Context, log *logger.Logger, cfg *viper.Viper, errChan chan
return server, nil
}

func createListener(ctx context.Context, cli *client.Client, p *chainParams) (event.Listener, error) {
func createListener(ctx context.Context, cli *client.Client, p chainParams) (event.Listener, error) {
// listenerPoolCap is a capacity of a
// worker pool inside the listener. It
// is used to prevent blocking in neo-go:
Expand Down Expand Up @@ -988,9 +988,8 @@ func createListener(ctx context.Context, cli *client.Client, p *chainParams) (ev
return listener, err
}

func (s *Server) createClient(ctx context.Context, p *chainParams, errChan chan<- error) (*client.Client, error) {
name := p.name
endpoints := p.cfg.GetStringSlice(name + ".endpoints")
func (s *Server) createClient(ctx context.Context, p chainParams, errChan chan<- error) (*client.Client, error) {
endpoints := p.cfg.GetStringSlice(p.name + ".endpoints")
if len(endpoints) == 0 {
return nil, fmt.Errorf("%s chain client endpoints not provided", p.name)
}
Expand All @@ -1007,13 +1006,13 @@ func (s *Server) createClient(ctx context.Context, p *chainParams, errChan chan<
client.WithConnSwitchCallback(func() {
var err error

if name == morphPrefix {
if p.name == morphPrefix {
err = s.restartMorph()
} else {
err = s.restartMainChain()
}
if err != nil {
errChan <- fmt.Errorf("internal services' restart after RPC reconnection to the %s: %w", name, err)
errChan <- fmt.Errorf("internal services' restart after RPC reconnection to the %s: %w", p.name, err)
}
}),
client.WithConnLostCallback(func() {
Expand Down

0 comments on commit 8bbbec0

Please sign in to comment.