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

NUT-19: Cached Responses #195

Merged
merged 19 commits into from
Dec 3, 2024
Merged

Conversation

lollerfirst
Copy link
Contributor

@lollerfirst lollerfirst commented Nov 23, 2024

Cache every successful PostMintResponse, PostMeltResponse and PostSwapResponse using the respective requests as keys.
In case of a network error, clients can replay the same exact requests receive the same responses. This safe-guards against clients accidentally losing money because of connectivity issues.

Implementations:

Copy link
Collaborator

@gandlafbtc gandlafbtc left a comment

Choose a reason for hiding this comment

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

Not a grammar pro myself, but I think this is correct?

03.md Outdated Show resolved Hide resolved
04.md Outdated Show resolved Hide resolved
05.md Outdated Show resolved Hide resolved
@callebtc
Copy link
Contributor

callebtc commented Nov 24, 2024

Awesome work and thank you for the implementations. I wonder whether we want to add this to the existing NUTs or formulate it as a separate NUT.

In both cases, I think it would be better to formulate this as an optional feature. Right now it is formulated as a MUST.

@callebtc
Copy link
Contributor

One argument for putting this in its own NUT would be that we would have to add a note about caching into every method that we add (like bolt12) whereas it could be formulated more generally as "any endpoint that produces outputs" and we could reference the specific NUTs for mint/melt/swap (and further future methods).

This NUT should also defined a setting flag for each cached endpoint that we announce in the mint info (together with a TTL)

@callebtc callebtc changed the title Cached Responses NUT-XX: Cached Responses Nov 24, 2024
@callebtc
Copy link
Contributor

There are two unrelated files in the PR.

Questions in my mind:

  • Should we announce the TTL in the NUT-XX info setting?
  • Should we announce all cached paths in the NUT-XX setting or should we add a boolean setting flag to each cached nut (swap, mint, melt)?

@callebtc callebtc added new nut A new protocol NUT needs discussion Needs more discussion labels Nov 24, 2024
XX.md Outdated Show resolved Hide resolved
XX.md Outdated

## Requests & Responses

Any Mint implementation should elect a data structure `D` that maps request objects to their respective responses. `D` should be fit for fast insertion, look-up and deletion (eviction) operations.
Copy link
Contributor

Choose a reason for hiding this comment

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

Example: Redis?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

?

XX.md Outdated Show resolved Hide resolved
XX.md Outdated Show resolved Hide resolved
XX.md Outdated Show resolved Hide resolved
XX.md Outdated Show resolved Hide resolved
Copy link
Contributor

@callebtc callebtc left a comment

Choose a reason for hiding this comment

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

Left some minor corrections on first pass

XX.md Outdated Show resolved Hide resolved
XX.md Outdated Show resolved Hide resolved
XX.md Outdated Show resolved Hide resolved
XX.md Outdated Show resolved Hide resolved
@callebtc callebtc changed the title NUT-XX: Cached Responses NUT-19: Cached Responses Dec 3, 2024
@callebtc callebtc added ready Ready to merge and removed needs discussion Needs more discussion labels Dec 3, 2024
@callebtc callebtc merged commit fb3187f into cashubtc:main Dec 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new nut A new protocol NUT ready Ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants