Skip to content

Commit

Permalink
Fixing locking issue (#153)
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler Ruppert <{ID}+{username}@users.noreply.github.com>
  • Loading branch information
MechanicalTyler and Tyler Ruppert authored May 16, 2023
1 parent 2666dab commit 5083f65
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions relayer/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func (r *Relayer) Start(ctx context.Context) error {
defer ticker.Stop()

for range ticker.C {
locker.Lock()
processors, err := r.buildProcessors(ctx)
if err != nil {
log.WithFields(log.Fields{
Expand All @@ -67,12 +66,15 @@ func (r *Relayer) Start(ctx context.Context) error {

log.Info("trying to update external chain info")

if err := r.updateExternalChainInfos(ctx, processors); err != nil {
locker.Lock()
err = r.updateExternalChainInfos(ctx, processors)
locker.Unlock()

if err != nil {
log.WithFields(log.Fields{
"err": err,
}).Error("couldn't update external chain info. Will try again.")
}
locker.Unlock()
}
}()

Expand All @@ -90,12 +92,12 @@ func (r *Relayer) Start(ctx context.Context) error {
return ctx.Err()
}

locker.Lock()
processors, err := r.buildProcessors(ctx)
if err != nil {
return err
}

locker.Lock()
err = r.Process(ctx, processors)
locker.Unlock()

Expand Down

0 comments on commit 5083f65

Please sign in to comment.