Re: Fetch all blocks using node sdk #fabric-sdk-node

Madhwendar Thakur

Hello Mark,

Thank you for your reply. I will discuss with team here if we are good to go with off chain approach or just remove the date filter and fetch blocks, batch wise, like fetch blocks from latest block  to 10th block or whatever batch size is configured.

I appreciate your suggestions as well and if we go with off chain approach then ofcourse this will help us alot.

Thank you!

Thanks and Regards
Sr Group Lead @OATI

On Fri, 15 Jul 2022, 2:27 pm Mark Lewis, <Mark.S.Lewis@...> wrote:
The blocks in Fabric are just a chain of sequentially numbered blocks. They are not indexed by creation time. If you want to index them by creation time (or rather the timestamp of transactions contained within the block?) then I think the earlier suggestion of creating your own store is likely your best approach. You don't necessarily need to store all the blocks in your own off-chain database. You could maybe just build your own block index and then use the existing APIs to retrieve blocks in the numbered range derived from your index for a given date range as required.

Using the block eventing client API should be much quicker to retrieve a sequential set of blocks than requesting each one individually using the qscc chaincode:

This sample might be helpful:

Join to automatically receive all group messages.