Skip to content

Nut19 cache#330

Merged
robwoodgate merged 20 commits intocashubtc:mainfrom
d4rp4t:nut19-cache
Mar 10, 2026
Merged

Nut19 cache#330
robwoodgate merged 20 commits intocashubtc:mainfrom
d4rp4t:nut19-cache

Conversation

@d4rp4t
Copy link
Contributor

@d4rp4t d4rp4t commented Jul 20, 2025

Fixes: #328

Description

Adds internal support for retrying cached requests according to NUT-19, based on exponential backoff.

Changes

request.ts

  • extended request() with optional retry logic
  • added requestWithRetry() with exponential backoff

MintInfo.ts

  • added support for NUT-19 via checkNut19() method

Other

  • added Nut19Policy type

Note: Cached request usage is not yet implemented in the CashuMint class — waiting for approval.

PR Tasks

  • Open PR
  • run npm run test --> no failing unit tests
  • run npm run format

@gandlafbtc
Copy link
Collaborator

thanks for the PR @d4rp4t ! do you think this could be tested with an integration test? This would not only verify it works as expected, it also gives implementors an up to date example.

Copy link
Collaborator

@robwoodgate robwoodgate left a comment

Choose a reason for hiding this comment

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

Great work @d4rp4t! Love the use of exponential backoff, and the implementation looks solid (eyeballed: have not had a chance to test). I've noted a couple of minor nits and some suggestions for your consideration.

Copy link
Collaborator

@robwoodgate robwoodgate left a comment

Choose a reason for hiding this comment

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

Would be a good spot to leverage our new logger as well

@d4rp4t d4rp4t requested a review from robwoodgate August 1, 2025 10:05
Copy link
Contributor

@a1denvalu3 a1denvalu3 left a comment

Choose a reason for hiding this comment

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

In a follow up to this PR we should make it possible to pass in a callback that takes in the request payload as a parameter, so the implementor can actually persist the payload data somewhere if they want to.

robwoodgate
robwoodgate previously approved these changes Aug 13, 2025
Copy link
Collaborator

@robwoodgate robwoodgate left a comment

Choose a reason for hiding this comment

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

Great work @d4rp4t!

@Egge21M Egge21M linked an issue Aug 14, 2025 that may be closed by this pull request
@a1denvalu3
Copy link
Contributor

@d4rp4t is this ready?

@d4rp4t
Copy link
Contributor Author

d4rp4t commented Aug 18, 2025

@lollerfirst The logic itsef - yes, but i haven't implemented it in any method yet.

@d4rp4t
Copy link
Contributor Author

d4rp4t commented Sep 10, 2025

#356 related, since i'll be able to write integration tests with the CDK mint

@Egge21M Egge21M linked an issue Sep 14, 2025 that may be closed by this pull request
@robwoodgate
Copy link
Collaborator

@d4rp4t - I've rebased this to development (v3) as discussed. Please can you check it over.

@robwoodgate robwoodgate added the v3 label Oct 30, 2025
@robwoodgate robwoodgate added the needs rebase This PR needs to be rebased to development because it contains merge conflicts label Dec 9, 2025
@d4rp4t d4rp4t force-pushed the nut19-cache branch 2 times, most recently from f475cc7 to 1cb5f11 Compare January 10, 2026 17:22
@d4rp4t d4rp4t marked this pull request as ready for review January 10, 2026 22:18
Copy link
Collaborator

@Egge21M Egge21M left a comment

Choose a reason for hiding this comment

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

Thank you so much for picking this up again! This already looks very solid. I left a couple notes on on the global options. Conceptionally the only thing that needs some thought is the backoff count and timer, leading to very very long promises in network failure situations.

@d4rp4t d4rp4t requested a review from Egge21M January 11, 2026 15:14
@robwoodgate robwoodgate removed the needs rebase This PR needs to be rebased to development because it contains merge conflicts label Jan 12, 2026
@robwoodgate
Copy link
Collaborator

Hav

Thank you so much for picking this up again! This already looks very solid. I left a couple notes on on the global options. Conceptionally the only thing that needs some thought is the backoff count and timer, leading to very very long promises in network failure situations.

Code looks great now these items have been addressed. Let's talk about the broader point raised and callbacks in our meeting this week?

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18c6b3c49e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1667153cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@robwoodgate robwoodgate dismissed Egge21M’s stale review March 5, 2026 22:52

changes outdated / done

robwoodgate
robwoodgate previously approved these changes Mar 5, 2026
Copy link
Collaborator

@robwoodgate robwoodgate left a comment

Choose a reason for hiding this comment

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

@d4rp4t - hope you don't mind, I fixed up the AbortController issue and a couple of nits highlighted by codex.

This looks really solid, you've done an amazing job on it.

LGTM!

@d4rp4t
Copy link
Contributor Author

d4rp4t commented Mar 5, 2026

@robwoodgate woah, thanks for fixing my mistakes. glad that we finally managed to finish it!

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9acf8e1b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b5cdffe9d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@robwoodgate robwoodgate added the needs review PR needs reviewers to give it the green light label Mar 6, 2026
@ye0man ye0man moved this from Needs Review to In Review in cashu-ts Mar 10, 2026
@robwoodgate
Copy link
Collaborator

LGTM

@robwoodgate robwoodgate merged commit 32b4085 into cashubtc:main Mar 10, 2026
11 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in cashu-ts Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review PR needs reviewers to give it the green light

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

NUT-19 cached response - Handle app close mid request Implement Caching layer for NUT-19

7 participants