更新频道配置过程中共有03个主要阶段:
在尝试调用updateChannel()
函数时,在步骤(3)出现错误:
{状态:“ BAD_REQUEST”,
信息:'错误授权更新:错误验证DeltaSet:不满足[Value] / Channel / Orderer / BatchSize的策略:无法达到1个子策略的隐式阈值,需要剩余1个子策略'}
我遵循了 hyperledger-sdk-node 存储库中有关频道更新here
的代码网络订购者的政策如下(我不确定我遇到的问题)
# Policies defines the set of policies at this level of the config tree
# For Orderer policies, their canonical path is
# /Channel/Orderer/<PolicyName>
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
# BlockValidation specifies what signatures must be included in the block
# from the orderer for the peer to validate it.
BlockValidation:
Type: ImplicitMeta
Rule: "ANY Writers"
有关相关代码的更多信息:
let signatures = [];
signatures.push(client.signChannelConfig(config_proto));
let request = {
name: channelName,
// orderer: channel.getOrderer("orderer.example.com"), // Do I really need this?
config: config_proto, // response from requesting configtxlator/compute
txId: client.newTransactionID(),
signatures: signatures
};
try {
let result = await client.updateChannel(request); // ERROR HERE
console.log("result", result);
} catch (error) {
console.log(error);
}
如果您需要更多信息,请告诉我!任何想法都应该有帮助
答案 0 :(得分:0)
我找到了一种使该功能生效的方法!
对于我来说,我想修改订购者配置的BatchSize
属性,该属性需要大多数订购组织管理员(more detail)的签名。
修改完成后,我需要由订购者的管理员签署请求。
以下代码包括:
(1)获取订购者管理员的key
和certificate
:
const keyPath = path.join(__dirname, '../../fabric/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/keystore');
const keyPEM = Buffer.from(readAllFiles(keyPath)[0]).toString();
const certPath = path.join(__dirname, '../../fabric/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/signcerts');
const certPEM = readAllFiles(certPath)[0];
(2)为client
分配签名身份:
client.setAdminSigningIdentity(keyPEM.toString(), certPEM.toString(), "OrdererMSP");
现在可以签名并发送给订购者了!
let signatures = [];
signatures.push(client.signChannelConfig(config_proto));
let request = {
name: channelName,
config: config_proto, // response from requesting configtxlator/compute
txId: client.newTransactionID(),
signatures: signatures
};
try {
let result = await client.updateChannel(request);
console.log("result", result);
} catch (error) {
console.log(error);
}
readAllFiles函数:
function readAllFiles(dir) {
const files = fs.readdirSync(dir);
const certs = [];
files.forEach((file_name) => {
const file_path = path.join(dir, file_name);
logger.debug(' looking at file ::' + file_path);
const data = fs.readFileSync(file_path);
certs.push(data);
});
return certs;
}