简体   繁体   中英

No transaction data in commercial-paper in hyperledger fabric

I am following commercial paper tutorial to learn some chaincode things. It is said in docs that there will be two things stored in database. First is the current state of the paper and second one is history of the paper's lifecycle, ie transaction data. But when I went through the couchdb after running issue, buy and reedem methods, I only saw the current state of paper not the history of the paper, ie, transaction data is not stored in database.

Am I missing something here, what things did I miss so that I didn't see the transaction data? Please help me.

Note that when using the contract api, each chaincode function that is called is passed a transaction context “ctx”, from which you can get the chaincode stub (GetStub() ), which has functions to access the ledger (eg GetState() ) and make requests to update the ledger (eg PutState() ).

Link: https://hyperledger-fabric.readthedocs.io/en/release-2.2/chaincode4ade.html#fabric-contract-api

Documentation of the Fabric Contract API in Go chaincode:

https://godoc.org/github.com/hyperledger/fabric-chaincode-go/shim#Chaincode

You can find the link of node.js document too.

So to get the history of an asset you have to use "func (*ChaincodeStub) GetHistoryForKey" API.

// GetHistoryForKey returns a history of key values across time.
// For each historic key update, the historic value and associated
// transaction id and timestamp are returned. The timestamp is the
// timestamp provided by the client in the proposal header.
// GetHistoryForKey requires peer configuration
// core.ledger.history.enableHistoryDatabase to be true.
// The query is NOT re-executed during validation phase, phantom reads are
// not detected. That is, other committed transactions may have updated
// the key concurrently, impacting the result set, and this would not be
// detected at validation/commit time. Applications susceptible to this
// should therefore not use GetHistoryForKey as part of transactions that
// update ledger, and should limit use to read-only chaincode operations.
GetHistoryForKey(key string) (HistoryQueryIteratorInterface, error)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM