Skip to content

Atomic #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2025
Merged

Atomic #122

merged 2 commits into from
May 2, 2025

Conversation

benma
Copy link
Contributor

@benma benma commented May 2, 2025

No description provided.

Better clarity and composes better with generic functions returning a
single value.
Some API calls, like BTCSign, or BluetoothUpgrade, require a series of
request<>response pairs. If the device gets an unexpected message, it
fails.

However, this is not concurrency safe - if another goroutine sends
something in the middle of it, the API call in progress and the
interrupting call both fail.

To solve this, we introduce `apiLock` that ensures a series of queries
does not get interrupted.

Most API functions only use a single query, so we acquire this lock by
default in `.query()`.

We add a `nonAtomicQuery()` variant with a `atomicQueries()` helper
function to enable making a series of calls.
Copy link
Collaborator

@NickeZ NickeZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@benma benma merged commit d958ecb into BitBoxSwiss:master May 2, 2025
3 checks passed
@benma benma deleted the atomic branch May 2, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants