Skip to content

Commit

Permalink
Fix data race on hcr.channels
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Litvinov <[email protected]>
  • Loading branch information
Zensey committed Mar 4, 2024
1 parent d6e4124 commit 4ffa546
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions session/pingpong/hermes_channel_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ func (hcr *HermesChannelRepository) Subscribe(bus eventbus.Subscriber) error {
}

func (hcr *HermesChannelRepository) handleHermesPromiseReceived(payload pingEvent.AppEventHermesPromise) {
// protect hcr.channels: handleHermesPromiseReceived->updateChannelWithLatestPromise->updateChannel
hcr.lock.RLock()
defer hcr.lock.RUnlock()

channelID, err := crypto.GenerateProviderChannelID(payload.ProviderID.Address, payload.HermesID.Hex())
if err != nil {
log.Err(err).Msg("could not generate provider channel id")
Expand Down

0 comments on commit 4ffa546

Please sign in to comment.