Skip to content

Commit

Permalink
morph/client: Prevent duplicated subscription to notary requests
Browse files Browse the repository at this point in the history
Not expected in practice, but still have to be checked.

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Dec 7, 2023
1 parent 598259b commit 5655887
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/morph/client/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,19 @@ func (c *Client) ReceiveNotaryRequests(txSigner util.Uint160) error {
return ErrConnectionLost
}

c.subs.Lock()
defer c.subs.Unlock()

if _, ok := c.subs.subscribedNotaryEvents[txSigner]; ok {
return nil
}

_, err := c.client.ReceiveNotaryRequests(&neorpc.TxFilter{Signer: &txSigner}, c.subs.curNotaryChan)
if err != nil {
return fmt.Errorf("block subscriptions RPC: %w", err)
}

c.subs.Lock()
c.subs.subscribedNotaryEvents[txSigner] = struct{}{}
c.subs.Unlock()

return nil
}
Expand Down

0 comments on commit 5655887

Please sign in to comment.