我正在研究fabcar智能合约的golang版本,同时寻求实现Java-SDK API,该API注册管理员,注册用户并基于https://github.com/hyperledger/fabric-samples/tree/master/fabcar/java执行查询更新值操作
我已经成功建立了3个org-9对等点的区块链网络,在对等点上安装,实例化并调用了链码。
但是,当我正在努力实现相对API时,我只能成功查询区块链数据库,同时得到“无法满足链码mycc的认可政策”
请在下面找到相对错误的屏幕截图
认可政策为“ OR('Org1MSP.member','Org2MSP.member','Org3MSP.member')”。
注册用户是否应该以某种方式获得Org1 / Org2 / Org3.member属性?任何线索将不胜感激!
答案 0 :(得分:0)
就像@IkarPohorský所说,对我来说,使用正确的方法名称后,此问题得到解决。另外,如果重新创建了HLF n / w,请确保删除“ wallet”文件夹,以便重新生成用户。
@Test
public void testMyMethodToBeInvoked() throws Exception {
deleteDirectory(".\\wallet");
EnrollAdmin.main(null);
RegisterUser.main(null);
// Load a file system based wallet for managing identities.
final Path walletPath = Paths.get("wallet");
final Wallet wallet = Wallet.createFileSystemWallet(walletPath);
// load a CCP
final Path networkConfigPath = Paths
.get("C:\\sw\\hlf146-2\\fabric-samples\\first-network\\connection-org1.yaml");
final Gateway.Builder builder = Gateway.createBuilder();
builder.identity(wallet, "user1").networkConfig(networkConfigPath).discovery(true);
// create a gateway connection
try (Gateway gateway = builder.connect()) {
final Network network = gateway.getNetwork("mychannel");
final Contract contract = network.getContract("mycc");
String myJSONString="{\"a\":\"b\"}";
byte[] result;
// Following did NOT work. Control goes directly to 'invoke' when 'submitTransaction' is done directly. 'invoke' need not be mentioned here.
// result = contract.submitTransaction("invoke", myJSONString);
// Following DID work. In chaincode (my chain code was Java) I had a method named 'myMethodToBeInvoked'. The chain code was written similar to https://github.com/hyperledger/fabric-samples/blob/release-1.4/chaincode/chaincode_example02/java/src/main/java/org/hyperledger/fabric/example/SimpleChaincode.java
result = contract.submitTransaction("myMethodToBeInvoked", my);
System.out.println(new String(result));
}
}
编辑:另外,请记住,如果您的链码抛出errorResponse,即使这样,我们也可能会遇到此签注失败问题。因此,请检查您的链式代码是否正常运行。