hyperledger / hyperledger/fabric-samples

Error while fetching asset modification history through REST

Open
#1,058 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3k
Forks
3.5k
Avg merge
3d 20h
Merged PRs (30d)
6

Description

Hello team,
I am using hyperledger fabric 2.4.9 test-network to build an application, the chaincode is written in Go using contract api.
I have exposed the chaincode functions as REST API using `express js` and I have used the scripts `AppUtil.js` and `CAUtil.js`
available under `test-application/javascript` directory in `fabric-samples`.
When I invoke the chaincode methods using the peer command in my CLI all my methods work fine as expected.
When I start the express server for` peerOrganization - org1`(known as orgA in my case) and test the methods from Postman client
from the desktop everything works fine.
However, When I start the express server for` peerOrganization - org2`(knows as orgB in my case) and test the methods from Postman client from the desktop, the REST API for invoking the` getHistoryForTransaction`(which takes in transaction ID as a parameter in the url) throws an error which implies that there is no data in `HistoryDB` in the network, despite the asset being created and present in the ledger, all other API's for querying the asset work as expected. The issue is faced only when invoking the `getHistoryForTransaction` which calls `GetHistoryForKey()` for getting the asset modification history.
Once, I am not able to fetch the history, the API stops working for orgA also and even from the `peer CLI` I get an error.

I am attaching the screenshot of my getTransactionHistory function and the rest api as well as the error.

I have tried checking the peer logs and debugging the functions but I am not able to resolve this issue. Please help
![GetTransactionHistory-function-chaincode-go](https://github.com/hyperledger/fabric-samples/assets/54268404/e4a8e824-33f0-4d8d-a94a-32e9ec6dd96b)
![expressJs-api-gettransactionhistory](https://github.com/hyperledger/fabric-samples/assets/54268404/99781b52-58c7-48f9-9479-09714d89e24d)
![error-expressjs-console-cli](https://github.com/hyperledger/fabric-samples/assets/54268404/7978aeaf-cafd-4002-9a97-f243b99f214b)
![error-peer-cli](https://github.com/hyperledger/fabric-samples/assets/54268404/4ea71bea-32b3-47f1-90ff-bb7f1047c94b)

Summary: The historyDB is getting timed out as it works as expected initially and then it fails sending a response even though asset exisits in the ledger

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.