Serve the chain tip and LightdInfo from cache - #577
Open
emersonian wants to merge 1 commit into
Open
Conversation
GetLatestBlock and GetLatestTreeState issued a getblockchaininfo to the backend on every call, and GetLightdInfo issued getinfo plus getblockchaininfo. Wallets poll all three, so a busy server generated backend RPC load proportional to client count for data it already had. Serve the tip from the block cache, which the ingestor already keeps current, and give GetLightdInfo a 5 second TTL — its fields are static or slow-moving. Both fall back to the RPC when the cache is disabled (--nocache) or still empty during initial sync, so behaviour is unchanged in those cases. GetLightdInfo returns a proto.Clone of the cached message rather than a struct copy, since LightdInfo embeds a mutex.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Not an NU6.3 urgency. I am in the process of porting over specific lightwalletd changes from the Zec.rocks fork, used on testnet and mainnet over the past year.)
GetLatestBlock and GetLatestTreeState issued a getblockchaininfo to the backend on every call, and GetLightdInfo issued getinfo plus getblockchaininfo. Wallets poll all three, so a busy server generated backend RPC load proportional to client count for data it already had.
This update serves the tip from the block cache, which the ingestor already keeps current, and gives GetLightdInfo a 5 second TTL. Both fall back to the RPC when the cache is disabled (--nocache) or still empty during initial sync, so behavior is unchanged in those cases.