我正在尝试在基本网络上编写一个结构网关应用程序,我的代码如下所示。
public static void main(String[] args) throws Exception {
// Load a file system based wallet for managing identities.
Path walletPath = Paths.get("wallet");
Wallet wallet = Wallet.createFileSystemWallet(walletPath);
// load a CCP
Path networkConfigPath = Paths.get("..", "..", "basic-network", "connection.yaml");
Gateway.Builder builder = Gateway.createBuilder();
builder.identity(wallet, "user1");
builder.networkConfig(networkConfigPath).discovery(true);
// create a gateway connection
try (Gateway gateway = builder.connect()) {
System.out.println("Hello");
}
catch(Exception e) {
e.printStackTrace();
}
}
当我运行代码时,它会抛出错误
Exception in thread "main" java.lang.IllegalStateException: The gateway identity must be set
请帮我看看如何设置这个网络的身份?
我的 connection.yaml 是
name: basic-network
version: 1.0.0
client:
organization: Org1
connection:
timeout:
peer:
endorser: '300'
orderer: '300'
channels:
mychannel:
orderers:
- orderer.example.com
peers:
peer0.org1.example.com: {}
organizations:
Org1:
mspid: Org1MSP
peers:
- peer0.org1.example.com
certificateAuthorities:
- ca.example.com
orderers:
orderer.example.com:
url: grpc://localhost:7050
peers:
peer0.org1.example.com:
url: grpc://localhost:7051
certificateAuthorities:
ca.example.com:
url: http://localhost:7054
caName: ca.example.com
有一个名为的文件夹User1@org1.example.com
位于basic-network/crypto-config/peerOrganizations/org1.example.com/users/