zebra
zebra copied to clipboard
Send the same getblocktemplate RPC response until the template would change
Motivation
str4d told us that zcashd
caches its getblocktemplate
RPC response when the RPC is called frequently. This can improve RPC performance, which is important for miner profits.
The getblocktemplate
response must change when:
- the best tip hash changes (Zebra's
ChainTip
watch channel) - the max time is reached
The getblocktemplate
response can also change, but is not required to change, when:
- the mempool adds or evicts transactions
Designs
- Cache the
getblocktemplate
RPC response based on the long polling ID - Delete the cached RPC value if the long polling ID would change
- If there is a cached value, return it when the RPC is called
- Don't cache invalid templates (like #6037)
- Mark invalid templates in the cache so we don't try to re-send or re-check them
- Return a RPC error if we don't find a valid template within a target block interval or two
Related Work
This will be easy to implement after long polling support in #5720