Skip to content

Conversation

@niteshbalusu11
Copy link
Member

No description provided.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces two significant and well-executed improvements. On the backend, it refactors the lnurlp endpoint to be stateless by using Redis for invoice storage instead of an in-memory channel map. This is a great architectural change that enhances scalability. On the frontend, it adds comprehensive support for light and dark themes, creating a more polished user experience. The implementation uses a centralized theme hook and correctly applies theme-aware colors and styles throughout the application.

My review includes a couple of minor suggestions for maintainability, such as using constants for a hardcoded color value in the frontend and moving function-scoped constants to the module level in the backend. Overall, this is a high-quality contribution.

* this makes the lnurl endpoint stateless. the one downside is that you're having to poll redis so it's a lot of reads but in my opinion that shouldn't be a big deal.
@niteshbalusu11 niteshbalusu11 force-pushed the make-lnurl-endpoint-stateless branch from a7d7865 to 3f0e755 Compare December 7, 2025 05:13
@niteshbalusu11
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully refactors the lnurl endpoint to be stateless by replacing an in-memory DashMap with a Redis-based InvoiceStore. This is an excellent architectural improvement for scalability and robustness. The new implementation correctly uses a polling mechanism to wait for invoices. The code is well-structured, and the new tests are comprehensive. I have one suggestion to enhance logging within the polling logic for better observability.

@BlixtWallet BlixtWallet deleted a comment from gemini-code-assist bot Dec 7, 2025
@niteshbalusu11
Copy link
Member Author

/gemini summary

@gemini-code-assist
Copy link
Contributor

Summary of Changes

This pull request significantly improves the scalability and robustness of the LNURL endpoint by transitioning its invoice management from an ephemeral in-memory cache to a persistent Redis store. This change ensures that invoice data is reliably stored and accessible across service instances, making the endpoint truly stateless and more resilient to application restarts or failures. The implementation includes a new Redis-backed storage mechanism and an updated invoice retrieval process that polls the Redis store.

Highlights

  • Stateless LNURL Endpoint: The LNURL endpoint has been refactored to be stateless by moving invoice data storage from an in-memory DashMap to Redis, enhancing scalability and resilience.
  • Redis-backed Invoice Storage: A new InvoiceStore module has been introduced, utilizing deadpool-redis to manage invoice storage, retrieval, and removal in Redis with a 60-second TTL.
  • Polling Mechanism for Invoices: The lnurlp_request function now employs a polling mechanism to retrieve invoices from Redis, replacing the previous oneshot channel-based approach, with configurable poll intervals and timeouts.
  • Dependency Removal: The dashmap dependency has been removed from the project, reflecting the shift away from in-memory caching for invoice data.
  • Comprehensive Testing: New test cases have been added to validate the functionality of the submit_invoice endpoint and the InvoiceStore, covering scenarios like storing, retrieving, removing, overwriting, and handling authentication.
Changelog
  • Cargo.lock
    • Removed 'dashmap' dependency.
  • server/Cargo.toml
    • Removed 'dashmap' dependency.
  • server/src/cache/invoice_store.rs
    • Added new module 'invoice_store.rs' for Redis-backed invoice storage.
    • Implemented InvoiceStore struct with store, get, and remove methods for invoices, utilizing deadpool-redis.
  • server/src/cache/mod.rs
    • Exported the new invoice_store module.
  • server/src/main.rs
    • Removed DashMap import.
    • Integrated InvoiceStore into the AppStruct.
    • Initialized InvoiceStore using the RedisClient.
    • Cloned RedisClient to allow both K1Store and InvoiceStore to use the same client instance.
  • server/src/routes/gated_api_v0.rs
    • Modified submit_invoice function to store invoices in the new InvoiceStore (Redis) instead of the DashMap.
    • Added error handling for Redis storage operations.
  • server/src/routes/public_api_v0.rs
    • Replaced tokio::sync::oneshot and tokio::time::timeout with tokio::time::sleep for invoice retrieval.
    • Introduced POLL_INTERVAL and TIMEOUT constants for the new polling mechanism.
    • Updated lnurlp_request to poll the InvoiceStore for invoice data, removing DashMap interactions.
  • server/src/tests/common.rs
    • Removed DashMap import.
    • Updated test setup to use InvoiceStore instead of DashMap for invoice management.
    • Added setup_test_invoice_store function for test environment setup.
    • Registered the /lnurlp/submit_invoice route in the test router.
  • server/src/tests/gated_invoice_tests.rs
    • Added new test file gated_invoice_tests.rs.
    • Implemented tests for submit_invoice endpoint covering storing, retrieving, removing, and overwriting invoices.
    • Included tests for authentication requirements and handling of non-existent invoices.
  • server/src/tests/mod.rs
    • Included the new gated_invoice_tests module.
Activity
  • niteshbalusu11 requested a review from gemini-code-assist[bot].
  • gemini-code-assist[bot] suggested moving polling constants (POLL_INTERVAL, TIMEOUT) from function scope to module level for better organization and reuse.
  • gemini-code-assist[bot] recommended logging a warning if state.invoice_store.remove() fails to aid in debugging potential issues with stale data or Redis connectivity.
  • niteshbalusu11 requested a summary from gemini-code-assist[bot].

@niteshbalusu11 niteshbalusu11 merged commit d1b944a into master Dec 7, 2025
8 checks passed
@niteshbalusu11 niteshbalusu11 deleted the make-lnurl-endpoint-stateless branch December 7, 2025 20:33
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