-
Notifications
You must be signed in to change notification settings - Fork 4
perf: cache LNDg channel data globally to reduce API calls #34
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
Conversation
- Add fetch_all_channels() that fetches all channels once and caches by pubkey - Refactor get_channels_to_modify() to use cached data instead of per-peer API calls - Reduces API calls from N (one per peer) to 1 (one per script run) Tests passing: 4/4
Summary of ChangesHello @TrezorHannes, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial performance enhancement to the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this 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 a significant performance improvement by caching LNDg channel data, which will drastically reduce API calls from one per peer to one per script run. The implementation is clean and effectively uses a global cache. I've identified a high-severity issue with how the cache is handled during API failures, which could lead to incorrect behavior for subsequent operations within the same script run. Additionally, there's a medium-severity robustness issue related to date string parsing. I've provided a single, comprehensive code suggestion that addresses both of these points to make applying the fix straightforward. Overall, this is an excellent enhancement that will improve the script's efficiency and reliability.
- Move cache initialization after API success to prevent empty cache on failure - Reset cache to None on API failure to allow retry on next call - Add try-except fallback for date parsing without fractional seconds Tests passing: 4/4
PR: Optimize fee_adjuster.py with Global Channel Cache
Summary of Changes
Detailed Changes
fee_adjuster.py
_CHANNEL_CACHEglobal variable to store channel data across peer iterationsfetch_all_channels(config)function that fetches all channels once and caches byremote_pubkeyget_channels_to_modify(pubkey, config)to use cached data via simple dict lookupPerformance Impact
Testing Strategy
calculate_fee_band_adjustmenttests pass (4/4)--debugrun verified identical fee calculationsWhat's Left for Later
get_last_peer_forwarding_timestampfetch_all_channels()andget_channels_to_modify()Checklist
write_charge_lnd_file: false) handled locally (gitignored)