1

更新通道配置的过程有 03 个主要阶段:

  • (1) 从 Orderer 获取最新的配置。
  • (2) 修改配置。
  • (3) 签署并发送交易给 Orderer 以更新通道配置。

我在尝试调用updateChannel()函数时在步骤 (3) 遇到错误:

{状态:'BAD_REQUEST',

信息:'错误授权更新:错误验证 DeltaSet:不满足 [Value] /Channel/Orderer/BatchSize 的策略:未能达到 1 个子策略的隐式阈值,需要剩余 1 个'}

我按照hyperledger-sdk-node repo 中关于 Channel update的代码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);
    }

如果您需要更多信息,请告诉我!任何想法都应该有帮助

4

1 回答 1

0

我找到了一种方法来使这件事起作用!

就我而言,我想修改BatchSize订购者配置的属性,这需要大多数订购组织管理员的签名(更详细)。

修改完成后,我需要订购者的管理员签署请求。

以下代码包括:

(1) 获取orderer's admin的keyand :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;
}
于 2019-04-12T08:37:52.897 回答