为了避免bug和编写高效的Hyperledger Fabric链码,应该遵循哪些最佳实践?
发布于 2018-07-24 16:06:23
超分类器织物链码编写通用指南.
有关该链接的详细说明,请参阅下面的链接:
https://gist.github.com/arnabkaycee/d4c10a7f5c01f349632b42b67cee46db
以下简要介绍了一些步骤:
使用日志记录是简单和容易的。使用织物的内置记录器。Fabric提供了如下的日志机制:
For Golang:https://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#ChaincodeLogger
For NodeJS:anchor
For :您可以使用任何标准的日志记录框架,比如Log4J
- _Couch DB Queries DO NOT alter the READ SET of a transaction_ - Mongo Queries are for querying the Key Value store aka StateDB only. It does not alter the read set of a transaction. This might lead to phantom reads in the transaction.
- _Only the DATA that you have stored in the couchDB is searchable_ - Do not be tempted to search for a key by its name using the MangoQuery. Although you can access the Fauxton console of the CouchDB, you cannot access a key by querying a key by which it is stored in the database. Example : Querying by _channelName\0000KeyName_ is not allowed. It is better to store your key as a property in your data itself.
rand.New(...)、t := time.Now()或甚至依赖未持久化到分类帐的全局变量(check )之类的语句。这是因为,如果生成的读写集不相同,验证系统链码可能会拒绝它并抛出一个ENDORSEMENT_POLICY_FAILURE。CORE_CHAINCODE_EXECUTETIMEOUT=60shttps://stackoverflow.com/questions/51503153
复制相似问题