Skip to content

Commit

Permalink
Revert "Fix data race on hcr.channels"
Browse files Browse the repository at this point in the history
This reverts commit f45a150.
  • Loading branch information
Zensey committed Mar 4, 2024
1 parent 36ef783 commit d6e4124
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions session/pingpong/hermes_channel_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,25 +454,20 @@ func (hcr *HermesChannelRepository) updateChannelWithLatestPromise(chainID int64
func (hcr *HermesChannelRepository) updateChannel(chainID int64, new HermesChannel) {
earningsOld := hcr.sumChannelsDetailed(chainID, new.Identity)

{
hcr.lock.Lock()
defer hcr.lock.Unlock()

updated := false

v := hcr.channels[chainID]
for i, channel := range v {
if channel.Identity == new.Identity && channel.HermesID == new.HermesID {
updated = true
hcr.channels[chainID][i] = new
break
}
}
res := append(hcr.channels[chainID], new)
if !updated {
hcr.channels[chainID] = res
updated := false

v := hcr.channels[chainID]
for i, channel := range v {
if channel.Identity == new.Identity && channel.HermesID == new.HermesID {
updated = true
hcr.channels[chainID][i] = new
break
}
}
res := append(hcr.channels[chainID], new)
if !updated {
hcr.channels[chainID] = res
}

log.Info().Msgf(
"Loaded state for provider %q, hermesID %q: balance %v, available balance %v, unsettled balance %v",
Expand Down

0 comments on commit d6e4124

Please sign in to comment.