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

Add ArcSwap to update Mint configuration at runtime #503

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

crodas
Copy link
Contributor

@crodas crodas commented Dec 16, 2024

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

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.
@thesimplekid thesimplekid added enhancement New feature or request mint labels Dec 16, 2024
use crate::mint_url::MintUrl;

/// Mint Inner configuration
pub struct Inner {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be pub?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

That’s better. 👍

Comment on lines 58 to +61
# -Z minimal-versions
sync_wrapper = "0.1.2"
bech32 = "0.9.1"
arc-swap = "1.7.1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

/// Mint Info
pub mint_info: MintInfo,
/// Mint Config
pub config: SwappableConfig,
/// Quotes ttl
pub quote_ttl: QuoteTTL,
Copy link
Collaborator

@thesimplekid thesimplekid Dec 17, 2024

Choose a reason for hiding this comment

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

Think the quote_ttl should also be in the swapable config?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants