Skip to content

Commit

Permalink
mixclient: Do not submit PRs holding client mutex
Browse files Browse the repository at this point in the history
The client mutex was being held during the initial publishing of pair request
messages to prevent a situation where a submit errored but the peer was still
associated with the client, or the message was submitted to mixpool and sent
to other peers but our local peer had not yet been associated to the client at
the time an epoch tick occurred.  This should not be a situation we will
encounter anymore, since the PR submissions are spaced out intentionally to
avoid sending them close to the epoch.
  • Loading branch information
jrick committed Jul 5, 2024
1 parent 7b0893d commit f8d7666
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mixing/mixclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,16 +744,18 @@ func (c *Client) Dicemix(ctx context.Context, cj *CoinJoin) error {
c.pairings[string(pairingID)] = pairing
}
pairing.localPeers[*p.id] = p
c.mu.Unlock()

err = p.submit(pr)
if err != nil {
c.mu.Lock()
delete(pairing.localPeers, *p.id)
if len(pairing.localPeers) == 0 {
delete(c.pairings, string(pairingID))
}
c.mu.Unlock()
return err
}
c.mu.Unlock()

select {
case res := <-p.res:
Expand Down

0 comments on commit f8d7666

Please sign in to comment.