Skip to content

Commit

Permalink
electrumx: fix race condition in client (#4)
Browse files Browse the repository at this point in the history
Previously, the request ID stored in the client was incremented while
the lock was held, however it was then read without the lock being held.
  • Loading branch information
joshuasing authored Feb 27, 2024
1 parent 7c778c0 commit 9535e48
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hemi/electrumx/electrumx.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,13 @@ func (c *Client) call(ctx context.Context, method string, params, result any) er

c.mtx.Lock()
c.id++
id := c.id
c.mtx.Unlock()

req := &JSONRPCRequest{
JSONRPC: "2.0",
Method: method,
ID: c.id,
ID: id,
}
if params != any(nil) {
b, err := json.Marshal(params)
Expand Down

0 comments on commit 9535e48

Please sign in to comment.