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

Save and load exchange rates with persistent JSON file #13

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

JBetz
Copy link
Contributor

@JBetz JBetz commented Apr 16, 2024

Resolves #12.

The exchange rates map is now persisted in <datadir>/exchangerates.json whenever it is updated via the new setfeeexchangerates RPC.

Also, the server parameter exchangeratesjsonfile has been renamed to initialexchangeratesjsonfile to distinguish it from the database file. If the initialization file isn't provided and the database file doesn't exist, it will be created at startup with a default valuation for the policy asset. And if the initialization file is provided and the database file already exists, it will be overwritten with the values in the initialization file. In any case, the initialization file will never be modified by the node unless it resolves to the same path as the database file.

I also switched to using as much of the existing functionality for saving and loading settings found in <util/settings.h>, since settings are also persisted as a JSON file in <datadir>. The banlist database also uses the same mechanisms.

@JBetz JBetz requested a review from Mixa84 as a code owner April 16, 2024 20:07
@JBetz JBetz requested a review from fare April 17, 2024 14:55
@JBetz
Copy link
Contributor Author

JBetz commented Apr 18, 2024

Added some functional tests which verify that 1) the initial exchange rates are loaded from the initial exchange rates JSON file when provided, 2) the in-memory and on-disk exchange rates are kept in synch whenever the exchange rates are updated via the setfeeexchangerates RPC, 3) the RPC returns a helpful error message when the inputs fail to parse, and 4) that the exchange rates aren't modified when this happens.

@Mixa84 Mixa84 merged commit 6eb6a32 into dev Apr 18, 2024
1 check passed
@Mixa84 Mixa84 deleted the exchange-rates-refactor branch April 18, 2024 15:23
JBetz added a commit that referenced this pull request Apr 19, 2024
* Refactor exchange rates loading and saving

* Use given path for exchange rates config, not relative path from data directory

* Add separate tests for exchange rates RPCs
JBetz added a commit that referenced this pull request Apr 24, 2024
* Refactor exchange rates loading and saving

* Use given path for exchange rates config, not relative path from data directory

* Add separate tests for exchange rates RPCs
JBetz added a commit that referenced this pull request May 3, 2024
* Refactor exchange rates loading and saving

* Use given path for exchange rates config, not relative path from data directory

* Add separate tests for exchange rates RPCs
Mixa84 pushed a commit that referenced this pull request May 6, 2024
* Refactor exchange rates loading and saving

* Use given path for exchange rates config, not relative path from data directory

* Add separate tests for exchange rates RPCs
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