更新频道配置过程中有03个主要阶段:
在尝试调用updateChannel()
函数时,我在步骤(3)遇到错误,这是:
{status:'BAD_REQUEST',
info:'错误授权更新:错误验证DeltaSet:[Value] / Channel / Orderer / BatchSize的策略不满足:无法达到1个子策略的隐含阈值,需要1个剩余'}
我关注了关于频道更新here的hyperledger-sdk-node repo的代码
网络订货人的政策看起来像这样(我不确定我在这里遇到的问题)
# 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);
}
如果您需要更多信息,请告诉我!任何想法都应该有所帮助
我找到了让这件事有效的方法!
在我的例子中,我想修改orderer配置的BatchSize
属性,这需要大多数订购组织管理员(more detail)的签名。
修改完成后,我需要由订货人的管理员签署请求。
以下代码包括:
(1)获取orderer管理员的key
和certificate
:
const keyPath = path.join(__dirname, '../../fabric/crypto-config/ordererOrganizations/example.com/users/[email protected]/msp/keystore');
const keyPEM = Buffer.from(readAllFiles(keyPath)[0]).toString();
const certPath = path.join(__dirname, '../../fabric/crypto-config/ordererOrganizations/example.com/users/[email protected]/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;
}