如何解决Hyperledger Fabric-Chaincod-java-GetAllAssets:getStateByRange-合同方法执行期间发生错误
因此,我在fabric-samples项目和资产转移基础/ chaincode-java上进行了一些测试,我意识到可以成功调用所有方法,但只有GetAllAssets可以调用。 此方法调用名为getStateByRange(“”,“”)(带有空键)的函数,该函数应返回存储在区块链中的所有资产,但是,它将返回以下错误:
错误:调用期间认可失败。响应:状态:500消息:“模拟错误:事务返回失败:合同方法执行期间出错”
我注意到,当我使用StartKey和EndKey时,例如 getStateByRange(“ asset1”,“ asset7”) 可以正常工作,但是方法声明指出它可以与空键一起使用。
/**
* Returns all existing keys,and their values,that are lexicographically
* between <code>startkey</code> (inclusive) and the <code>endKey</code>
* (exclusive).
* <p>
* The keys are returned by the iterator in lexical order. Note that startKey
* and endKey can be empty string,which implies unbounded range query on start
* or end.
* <p>
* Call close() on the returned {@link QueryResultsIterator#close()} object when
* done.
*
* @param startKey key as the start of the key range (inclusive)
* @param endKey key as the end of the key range (exclusive)
* @return an {@link Iterable} of {@link KeyValue}
*/
QueryResultsIterator<KeyValue> getStateByRange(String startKey,String endKey);
所以这应该是错误还是什么,不是吗?因为我打算在没有startKey和endKey的情况下使用它,但是它无法按预期工作。
我注意到的另一件事是,对于每个非空值,都存在一个空条目。我运行了类似getStateByRange(“ a”,“ z”)的命令,它返回了以下结果。创建合同时可能会有一些错误。就像我说的,我正在测试默认的fabric-samples项目。
[{\"appraisedValue\":300,\"assetID\":\"asset1\",\"color\":\"blue\",\"owner\":\"Tomoko\",\"size\":5},{\"appraisedValue\":400,\"assetID\":\"asset2\",\"color\":\"red\",\"owner\":\"Brad\",{\"appraisedValue\":500,\"assetID\":\"asset3\",\"color\":\"green\",\"owner\":\"Jin Soo\",\"size\":10},{\"appraisedValue\":600,\"assetID\":\"asset4\",\"color\":\"yellow\",\"owner\":\"Max\",{\"appraisedValue\":700,\"assetID\":\"asset5\",\"color\":\"black\",\"owner\":\"Adrian\",\"size\":15},\"assetID\":\"asset6\",\"color\":\"white\",\"owner\":\"Michel\",{\"appraisedValue\":0,\"assetID\":null,\"color\":null,\"owner\":null,\"size\":0},\"size\":0}]"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。