问题描述
因此,我在fabric-samples项目和资产转移基础/ chaincode-java上进行了一些测试,我意识到可以成功调用所有方法,但只有GetAllAssets可以调用。 此方法调用名为getStateByRange(“”,“”)(带有空键)的函数,该函数应返回存储在区块链中的所有资产,但是,它将返回以下错误:@H_404_1@
我注意到,当我使用StartKey和EndKey时,例如 getStateByRange(“ asset1”,“ asset7”) 可以正常工作,但是方法声明指出它可以与空键一起使用。@H_404_1@
/**
* 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的情况下使用它,但是它无法按预期工作。@H_404_1@
我注意到的另一件事是,对于每个非空值,都存在一个空条目。我运行了类似getStateByRange(“ a”,“ z”)的命令,它返回了以下结果。创建合同时可能会有一些错误。就像我说的,我正在测试默认的fabric-samples项目。@H_404_1@
[{\"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 (将#修改为@)