-
Notifications
You must be signed in to change notification settings - Fork 2.1k
optimize get_spends RPC #19958
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
base: main
Are you sure you want to change the base?
optimize get_spends RPC #19958
Conversation
dd017b3
to
b7967d3
Compare
|
||
block: Optional[FullBlock] = await self.service.block_store.get_full_block(header_hash) | ||
if block is None: | ||
block_bytes: Optional[bytes] = await self.service.block_store.get_full_block_bytes(header_hash) | ||
if block_bytes is None: | ||
raise ValueError(f"Block {header_hash.hex()} not found") | ||
|
||
block_view = memoryview(block_bytes) | ||
height, _is_tx_block = get_height_and_tx_status_from_block(block_view) | ||
|
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.
We should be able to avoid this extra complexity by simply augmenting get_full_block_bytes
to return the height as well. We have it in the full_blocks
table it already queries.
buf = skip_reward_chain_block(buf) # reward_chain_block | ||
buf, height = height_from_reward_chain_block(buf) # reward_chain_block |
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.
We can avoid this added complexity by receiving height
in block_info_from_block
if we must (to keep returning this augmented GeneratorBlockInfo
) instead of computing it. The caller has it already.
This PR has been flagged as stale due to no activity for over 60 days. It will not be automatically closed, but it has been given a stale-pr label and should be manually reviewed by the relevant parties. |
Purpose:
Make some of the RPCs a bit cheaper.
GeneratorBlockInfo
include block height. This makes it possible to run the block generator just from this information.get_full_block()
->get_block_info()
in the RPCs that run blocks (which is cheaper).get_puzzle_and_solution_for_coin()
in the thread pool for RPCs.get_additions_and_removals
is really just a coin store lookup. We currently get the full block just to map the header hash to a height. Change this to parse out the block height withget_height_and_tx_status_from_block()
instead of constructing a full block.Current Behavior:
New Behavior: