Skip to content
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

Optimize DB stream chain #1060

Open
Neylix opened this issue May 31, 2023 · 0 comments
Open

Optimize DB stream chain #1060

Neylix opened this issue May 31, 2023 · 0 comments
Labels
DB Involve database enhancements

Comments

@Neylix
Copy link
Member

Neylix commented May 31, 2023

Describe the problem you discovered

Currently there is 2 functions in the ChainReader that read multiple transactions, stream_chain and get_transaction_chain.
stream_chain return a stream from the beginning of the chain in asc order
get_paginated_chain return a batch of 10 transactions in asc or desc order

Currently stream_chain use the same sub function process_get_chain than get_transaction_chain and it return a batch of 10 transactions while the stream could send transaction by transaction after reading it. Also this sub function does some extra work to calculate the field to fetch while this could be done only once before the stream.

In other side when we want to stream a chain in reverse order or from a paging_address we can only use get_transaction_chain which means open the file -> read 10 transactions -> close the file -> send these tx in the stream -> loop again to open file ... This is not really efficient

Describe the solution you'd like

I think we could have only one function stream_chain that can take an order and a paging address.
This function could send transaction by transaction on asc order (need to do batch of 10 tx in desc order) and it would open and close the file only once.

Additional context

Epic: #261

@Neylix Neylix added DB Involve database enhancements labels May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DB Involve database enhancements
Projects
None yet
Development

No branches or pull requests

1 participant