Hyperledger Fabric:背书政策三分之二。错误
Hyperledger Fabric: Endorsement policy two peers out of 3. Error
我正在与您联系,因为属于生命周期的 hyperledger fabric 背书策略出现异常。
我做了什么:
在同一个组织 MSP 中打包、安装、批准并提交了我的链代码到 9 个节点中的三个节点。
因为我有测试用例,所以我应该执行如下所示的背书策略:
OutOf(2, Org1MSP.member)
在我看来类似于:AND(Org1MSP.member, Org1MSP.member)
。我错了吗?
然而,当我发布我的链代码时,我收到了一条消息:
server returned: failed constructing descriptor for chaincodesname:"mycc": no peer combination can satisfy the endorsement policy
令人困惑的是,当我使用策略时:AND(Org1MSP.member)
一切都crystal 清楚并且我的链代码被调用。在这种情况下使用发现命令 returns 服务器上的每个对等点,太棒了。但这不是我想要实现的!我想强制执行 3 个背书人中的 2 个背书。
感谢您的帮助!
这是我的连接配置文件。仅包含三个背书节点:
---
certificateAuthorities:
Org1CA:
caName: ca
url: http://<IP is correct links to the right server>:7054
client:
connection:
timeout:
orderer: '300'
peer:
endorser: '300'
organization: Org1MSP
name: example.com
organizations:
Org1MSP:
certificateAuthorities:
- Org1CA
mspid: Org1MSP
peers:
- peer0.org1.example.com
- peer1.org1.example.com
- peer9.org1.example.com
peers:
peer0.org1.example.com:
url: grpc://peer0.org1.example.com:7051
peer9.org1.example.com:
url: grpc://peer9.org1.example.com16051
peer1.org1.example.com:
url: grpc://peer1.org1.example.com:8051
version: 1.0.0
每个对等点都在不同的机器上。
这是我如何执行事务调用的示例:
Gateway.Builder builder = Gateway.createBuilder();
Wallet wallet = Wallets.newInMemoryWallet();
X509Identity ident;
try {
ident = Identities.newX509Identity("Org1MSP",
Identities.readX509Certificate("removed key due to security porpuse"),
Identities.readPrivateKey("removed key due to security porpuse"));
String userName = "admin";
Contract contract = null;
InputStream input = classLoader.getResourceAsStream("connection-org1.yaml");
wallet.put("admin", ident);
builder.identity(wallet, userName).networkConfig(input).discovery(true);
Gateway gateway = builder.connect();
Network network = gateway.getNetwork("crm-field-1");
contract = network.getContract(contractName);
byte[] response = null;
Transaction trans = contract.createTransaction("createCrmContact");
Map<String, byte[]> data = new HashMap<String, byte[]>();
data.put("value", value.getBytes());
data.putAll(initialize());
trans = trans.setTransient(data);
response = trans.submit(pk, fieldName);
// response = contract.submitTransaction("createCrmContact", pk, fieldName,
// value);
LOGGER.error("Logging: Response - " + response);
if (response == null)
return null;
return decode(response);
} catch (Exception e) {
LOGGER.error("Logging: Error" + e.getMessage());
e.printStackTrace();
}
所以,我自己想通了:
如果网络没有设置任何Anchor peers,发现就会失败,因为没有端点,他从那里获取网络中每个人的信息。所以将它们添加到网络解决了我的问题。
谢谢大家的建议
我正在与您联系,因为属于生命周期的 hyperledger fabric 背书策略出现异常。
我做了什么:
在同一个组织 MSP 中打包、安装、批准并提交了我的链代码到 9 个节点中的三个节点。
因为我有测试用例,所以我应该执行如下所示的背书策略:
OutOf(2, Org1MSP.member)
在我看来类似于:AND(Org1MSP.member, Org1MSP.member)
。我错了吗?
然而,当我发布我的链代码时,我收到了一条消息:
server returned: failed constructing descriptor for chaincodesname:"mycc": no peer combination can satisfy the endorsement policy
令人困惑的是,当我使用策略时:AND(Org1MSP.member)
一切都crystal 清楚并且我的链代码被调用。在这种情况下使用发现命令 returns 服务器上的每个对等点,太棒了。但这不是我想要实现的!我想强制执行 3 个背书人中的 2 个背书。
感谢您的帮助!
这是我的连接配置文件。仅包含三个背书节点:
---
certificateAuthorities:
Org1CA:
caName: ca
url: http://<IP is correct links to the right server>:7054
client:
connection:
timeout:
orderer: '300'
peer:
endorser: '300'
organization: Org1MSP
name: example.com
organizations:
Org1MSP:
certificateAuthorities:
- Org1CA
mspid: Org1MSP
peers:
- peer0.org1.example.com
- peer1.org1.example.com
- peer9.org1.example.com
peers:
peer0.org1.example.com:
url: grpc://peer0.org1.example.com:7051
peer9.org1.example.com:
url: grpc://peer9.org1.example.com16051
peer1.org1.example.com:
url: grpc://peer1.org1.example.com:8051
version: 1.0.0
每个对等点都在不同的机器上。 这是我如何执行事务调用的示例:
Gateway.Builder builder = Gateway.createBuilder();
Wallet wallet = Wallets.newInMemoryWallet();
X509Identity ident;
try {
ident = Identities.newX509Identity("Org1MSP",
Identities.readX509Certificate("removed key due to security porpuse"),
Identities.readPrivateKey("removed key due to security porpuse"));
String userName = "admin";
Contract contract = null;
InputStream input = classLoader.getResourceAsStream("connection-org1.yaml");
wallet.put("admin", ident);
builder.identity(wallet, userName).networkConfig(input).discovery(true);
Gateway gateway = builder.connect();
Network network = gateway.getNetwork("crm-field-1");
contract = network.getContract(contractName);
byte[] response = null;
Transaction trans = contract.createTransaction("createCrmContact");
Map<String, byte[]> data = new HashMap<String, byte[]>();
data.put("value", value.getBytes());
data.putAll(initialize());
trans = trans.setTransient(data);
response = trans.submit(pk, fieldName);
// response = contract.submitTransaction("createCrmContact", pk, fieldName,
// value);
LOGGER.error("Logging: Response - " + response);
if (response == null)
return null;
return decode(response);
} catch (Exception e) {
LOGGER.error("Logging: Error" + e.getMessage());
e.printStackTrace();
}
所以,我自己想通了:
如果网络没有设置任何Anchor peers,发现就会失败,因为没有端点,他从那里获取网络中每个人的信息。所以将它们添加到网络解决了我的问题。
谢谢大家的建议