From 33c46dd59d10c04503f9b06426a9af9970351420 Mon Sep 17 00:00:00 2001 From: Ivan Belyakov Date: Mon, 5 Feb 2024 14:37:56 +0100 Subject: [PATCH] fix(protocol): crash in concurrent map write/read --- protocol/transport/envelopes_monitor.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/protocol/transport/envelopes_monitor.go b/protocol/transport/envelopes_monitor.go index cf164914d..5734f9c37 100644 --- a/protocol/transport/envelopes_monitor.go +++ b/protocol/transport/envelopes_monitor.go @@ -123,6 +123,9 @@ func (m *EnvelopesMonitor) Add(identifiers [][]byte, envelopeHashes []types.Hash return errors.New("hashes don't match messages") } + m.mu.Lock() + defer m.mu.Unlock() + for _, identifier := range identifiers { m.identifierHashes[string(identifier)] = envelopeHashes }