From d6e412492d449a9d047f2b3569d260ad47f2f603 Mon Sep 17 00:00:00 2001 From: Anton Litvinov Date: Mon, 4 Mar 2024 19:33:13 +0400 Subject: [PATCH] Revert "Fix data race on hcr.channels" This reverts commit f45a1508448a6d85e2e36e91f37f5fec30a3b00d. --- session/pingpong/hermes_channel_repository.go | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/session/pingpong/hermes_channel_repository.go b/session/pingpong/hermes_channel_repository.go index 60c84f3b35..0d58dfbba9 100644 --- a/session/pingpong/hermes_channel_repository.go +++ b/session/pingpong/hermes_channel_repository.go @@ -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",