Skip to content
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

Tech debt: no pattern is used when dealing with cached data in irmaclient.Client #365

Open
ivard opened this issue Dec 13, 2023 · 2 comments
Assignees

Comments

@ivard
Copy link
Member

ivard commented Dec 13, 2023

The irmaclient.Client struct currently caches various data, representing the data stored in irmaclient.storage. No specific pattern is followed in this caching process, making it difficult to detect errors in maintaining consistency between the cache and the storage.

Revocation poses a particular challenge because numerous updates are required when re-downloading the nonrevocation witness. These updates occur in background tasks. Currently, it is challenging to assess whether potential race conditions exist because strict module separation or other types of interfacing are not applied.

The cached storage is currently used, among other things, to calculate the choices the user currently has when starting a disclosure session. Presently, an update is sent for each session every time the cache is updated. This mechanism is fragile, and it would be better if each session kept its own administration and only received an event when updates occurred. In this sense, the 'sessions' struct is also considered a code smell.

@sietseringers
Copy link
Member

Presently, an update is sent for each session every time the cache is updated.

@ivard, when an issuance session completes then any open disclosure sessions are notified using this line. Is that what you meant with this?

@ivard
Copy link
Member Author

ivard commented Nov 22, 2024

Yes exactly. The issuance session updates both the cache and the files on disk and pokes all other sessions to reload their candidates. If one of these things is forgotten when making a change, really weird stuff can happen.

I think a good approach would be to do some research where in the code the cached client state is used (aka the "Stuff we manage on disk"). A nice goal would be to introduce an interface to separate the storage struct a bit from the rest of the code. If we need the cache functionality for performance reasons, it should be handled on the implementation side of this new interface, such that the rest of the code does not have to be aware of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants