Skip to content

Commit 6bc13b2

Browse files
committed
Merge remote-tracking branch origin/next-version into txgraph
2 parents f9aad3d + deca5ef commit 6bc13b2

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

server/internal/infrastructure/live-store/inmemory/tree_signing_session.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,14 @@ func (s *treeSigningSessionsStore) Get(roundId string) (*ports.MusigSigningSessi
5252
func (s *treeSigningSessionsStore) Delete(roundId string) {
5353
s.lock.Lock()
5454
defer s.lock.Unlock()
55-
close(s.nonceCollectedCh[roundId])
56-
close(s.sigsCollectedCh[roundId])
55+
56+
if _, exists := s.nonceCollectedCh[roundId]; exists {
57+
close(s.nonceCollectedCh[roundId])
58+
}
59+
if _, exists := s.sigsCollectedCh[roundId]; exists {
60+
close(s.sigsCollectedCh[roundId])
61+
}
62+
5763
delete(s.nonceCollectedCh, roundId)
5864
delete(s.sigsCollectedCh, roundId)
5965
delete(s.sessions, roundId)
@@ -72,13 +78,15 @@ func (s *treeSigningSessionsStore) AddNonces(
7278
if _, ok := session.Cosigners[pubkey]; !ok {
7379
return fmt.Errorf(`cosigner %s not found for round "%s"`, pubkey, roundId)
7480
}
81+
if _, exists := s.nonceCollectedCh[roundId]; !exists {
82+
return fmt.Errorf("nonce channel not initialized for round %s", roundId)
83+
}
7584

7685
s.sessions[roundId].Nonces[pubkey] = nonces
7786

7887
if len(s.sessions[roundId].Nonces) == s.sessions[roundId].NbCosigners-1 {
7988
s.nonceCollectedCh[roundId] <- struct{}{}
8089
}
81-
8290
return nil
8391
}
8492

@@ -95,6 +103,9 @@ func (s *treeSigningSessionsStore) AddSignatures(
95103
if _, ok := session.Cosigners[pubkey]; !ok {
96104
return fmt.Errorf(`cosigner %s not found for round "%s"`, pubkey, roundId)
97105
}
106+
if _, exists := s.sigsCollectedCh[roundId]; !exists {
107+
return fmt.Errorf("signature channel not initialized for round %s", roundId)
108+
}
98109

99110
s.sessions[roundId].Signatures[pubkey] = sigs
100111

0 commit comments

Comments
 (0)