Date
1 - 6 of 6
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 Madhwendar 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. |
|
Mark Lewis
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: |
|
Madhwendar Thakur
thanks Anup. Actually we have created an independent client application (Plain HTML and Js based) to show transactions in a meaningful way to end user and showing all these information in Tree Grid once user click on any transaction Id. But here we introduced another html page using which user can query to fetch blocks as per date filter, which is very much slow as there is no direct way of fetching blocks information from ledger as i explained earlier in my previous email. I already suggested for maintaining off chain database but that will introduce another dependency on using database like postgres or any other no sql supporting rich query platform. Infact hyperledger explore is also using off chain database. My question is : isn't it introducing security issues as one can delete data from off chain database? Also this could be an overhead for our clients to manage off chain database as well as another node will be deployed on our clients servers. So i was looking for a way where we could fetch all blocks using some inbuilt node api's. Please suggest for the same. Thanks and regards, Madhwendar Sr Group Lead @OATI On Wed, 13 Jul 2022, 2:04 pm Anup Gupta, <anup.gupta21@...> wrote:
|
|
Anup
use event on chaincode action store blockdetails in offchaindb and query one user request comes On Wed, Jul 13, 2022 at 2:00 PM Madhwendar Thakur <madhwendar@...> wrote:
|
|
Madhwendar Thakur
Dear team, Please find sometime to review my concern. Is it possible to fetch all blocks using node sdk ? If yes then how? Or if there is any other way too please let me know. Thanks & Regards Madhwendar Sr. Group Lead @OATI On Tue, 12 Jul 2022, 8:02 pm madhwendar via lists.hyperledger.org, <madhwendar=gmail.com@...> wrote: Hello team, |
|
Madhwendar Thakur
Hello team,
I am having an use-case where i have to show blocks as per date applied by the user. I am using hyper-ledger fabric v2.x with NodeJs sdk. Currently i am using for loop to fetch each block using QSCC chaincode function GetBlockByNumber, then fetching the date from channel header timestamp and comparing the timestamp with the one sent in the request by user. This is weird solution to fetch all the required blocks from ledger as per requested time stamp but I did not find any other solution to fetch all the blocks from the ledger. Could you please suggest a way where i can fetch all the blocks from ledger or any other way which can fetch all blocks quickly? Your help is much appreciated. Thanks and Regards, Madhwendar Thakur. |
|