繁体   English   中英

超级账本结构中的商业票据中没有交易数据

[英]No transaction data in commercial-paper in hyperledger fabric

我正在关注商业票据教程来学习一些链码的东西。 文档中说数据库中会存储两件事。 第一个是论文的当前状态,第二个是论文生命周期的历史,即交易数据。 但是当我运行issue,buy和reedem方法后去couchdb时,我只看到了paper的当前状态,而不是paper的历史,即交易数据没有存储在数据库中。

我在这里是否遗漏了什么,我遗漏了什么以至于我没有看到交易数据? 请帮我。

请注意,在使用合约 API 时,每个被调用的链码函数都会传递一个交易上下文“ctx”,您可以从中获取链码存根(GetStub()),它具有访问账本的函数(例如 GetState() )并请求更新分类帐(例如 PutState() )。

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

Go 链码中 Fabric Contract API 的文档:

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

您也可以找到 node.js 文档的链接。

因此,要获取资产的历史记录,您必须使用“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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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