Add ArcSwap to update Mint configuration at runtime #503

Merged
crodas merged 4 commits from swappable-config into main 2024-12-25 14:53:58 +00:00
crodas commented 2024-12-16 19:16:54 +00:00 (Migrated from github.com)

Description

The main goal is to change settings without having multiple RwLock everywhere, instead having ArcSwap to update the configuration without having access to a mutable reference to the Mint.

This will allow the RPC Server, or any other medium to update the Mint without minimum contention.

This is a pre-requisite for #476


Notes to the reviewers


Suggested CHANGELOG Updates

CHANGED

ADDED

REMOVED

FIXED


Checklist

### Description The main goal is to change settings without having multiple RwLock everywhere, instead having ArcSwap to update the configuration without having access to a mutable reference to the Mint. This will allow the RPC Server, or any other medium to update the Mint without minimum contention. This is a pre-requisite for #476 ----- ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ----- ### Suggested [CHANGELOG](https://github.com/cashubtc/cdk/blob/main/CHANGELOG.md) Updates <!-- Please do not edit the actual changelog but note what you changed here. --> #### CHANGED #### ADDED #### REMOVED #### FIXED ---- ### Checklist * [x] I followed the [code style guidelines](https://github.com/cashubtc/cdk/blob/main/CODE_STYLE.md) * [x] I ran `just final-check` before committing
davidcaseria (Migrated from github.com) reviewed 2024-12-17 00:01:15 +00:00
@ -0,0 +1,128 @@
//! Active mint configuration
davidcaseria (Migrated from github.com) commented 2024-12-17 00:01:09 +00:00

Does this need to be pub?

Does this need to be `pub`?
crodas (Migrated from github.com) reviewed 2024-12-17 01:23:25 +00:00
@ -0,0 +1,128 @@
//! Active mint configuration
crodas (Migrated from github.com) commented 2024-12-17 01:23:24 +00:00

The fact that it is accessed through get_config() (that I think I should rename to load()), I think it should be pub, at least pub(crate).

I'll think if that can be transparent, with something like Deref or something similar.

The fact that it is accessed through `get_config()` (that I think I should rename to `load()`), I think it should be pub, at least pub(crate). I'll think if that can be transparent, with something like Deref or something similar.
crodas (Migrated from github.com) reviewed 2024-12-17 04:34:21 +00:00
@ -0,0 +1,128 @@
//! Active mint configuration
crodas (Migrated from github.com) commented 2024-12-17 04:34:21 +00:00

I think these new names are better (9272347), what do you think?

I think these new names are better (9272347), what do you think?
davidcaseria (Migrated from github.com) reviewed 2024-12-17 10:57:00 +00:00
@ -0,0 +1,128 @@
//! Active mint configuration
davidcaseria (Migrated from github.com) commented 2024-12-17 10:57:00 +00:00

That’s better. 👍

That’s better. 👍
thesimplekid (Migrated from github.com) reviewed 2024-12-17 18:26:46 +00:00
thesimplekid (Migrated from github.com) commented 2024-12-17 18:23:00 +00:00

deps under the -Z minimal-version comment are for deps that are not a direct dep of ours, but whatever dependency of ours that pull them in does not properly define their minimal version. Since this is a direct dep of ours can we just move this above the comment.

deps under the -Z minimal-version comment are for deps that are not a direct dep of ours, but whatever dependency of ours that pull them in does not properly define their minimal version. Since this is a direct dep of ours can we just move this above the comment.
@ -40,20 +42,14 @@ pub use types::{MeltQuote, MintQuote};
/// Cashu Mint
thesimplekid (Migrated from github.com) commented 2024-12-17 18:25:03 +00:00

Think the quote_ttl should also be in the swapable config?

Think the quote_ttl should also be in the swapable config?
vnprc (Migrated from github.com) reviewed 2024-12-17 21:40:06 +00:00
@ -0,0 +25,4 @@
/// Mint configuration
///
/// This struct is used to configure the mint, and it is wrapped inside a ArcSwap, so it can be
/// updated at runtime without locking the shared config nor without requiriming a mutable reference
vnprc (Migrated from github.com) commented 2024-12-17 21:40:06 +00:00
/// updated at runtime without locking the shared config nor without requiring a mutable reference
```suggestion /// updated at runtime without locking the shared config nor without requiring a mutable reference ```
crodas commented 2024-12-24 00:55:05 +00:00 (Migrated from github.com)

@thesimplekid this PR is ready for another round of reviews.

@thesimplekid this PR is ready for another round of reviews.
thesimplekid (Migrated from github.com) approved these changes 2024-12-25 14:53:21 +00:00
thesimplekid (Migrated from github.com) left a comment
ACK 712fa5176dbe443ae89cd3ca7e59091cca32f157
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cashubtc/cdk!503
No description provided.