How to use the fabric-protos.common.ConfigGroup function in fabric-protos

To help you get started, we’ve selected a few fabric-protos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / caliper / packages / caliper-fabric / lib / fabric.js View on Github external
const writeVersion = 0;
        const appVersion = 1;
        const policyVersion = 0;

        // Build the readSet
        const readValues = {};
        readValues.Consortium = new common.ConfigValue();

        const readAppGroup = {};
        for (const mspId of channelObject.msps) {
            readAppGroup[mspId] = new common.ConfigGroup();
        }
        const readGroups = {};
        readGroups.Application = new common.ConfigGroup({ groups: readAppGroup });

        const readSet = new common.ConfigGroup({ version: readVersion, groups: readGroups, values: readValues });

        // Build the writeSet (based on consortium name and passed Capabiliites)
        const modPolicy = 'Admins';
        const writeValues = {};

        const consortium = new common.Consortium({ name: channelObject.consortium });
        writeValues.Consortium = new common.ConfigValue({ version: writeVersion, value: consortium.toBuffer() });

        if (channelObject.capabilities) {
            const capabilities = this._populateCapabilities(channelObject.capabilities);
            writeValues.Capabilities = new common.ConfigValue({ version: writeVersion, value: capabilities.toBuffer(), mod_policy: modPolicy });
        }

        // Write Policy
        const writePolicies = this._generateWritePolicy(policyVersion, modPolicy);
github hyperledger / caliper / packages / caliper-fabric / lib / create-channel.js View on Github external
const writeVersion = 0;
    const appVersion = 1;
    const policyVersion = 0;

    // Build the readSet
    const readValues = {};
    readValues.Consortium = new common.ConfigValue();

    const readAppGroup = {};
    for (const mspId of mspIds) {
        readAppGroup[mspId] = new common.ConfigGroup();
    }
    const readGroups = {};
    readGroups.Application = new common.ConfigGroup({ groups: readAppGroup });

    const readSet = new common.ConfigGroup({ version: readVersion, groups: readGroups, values: readValues });

    // Build the writeSet (based on consortium name and passed Capabiliites)
    const modPolicy = 'Admins';
    const writeValues = {};

    const consortium = new common.Consortium({ name: consortiumName });
    writeValues.Consortium = new common.ConfigValue({ version: writeVersion, value: consortium.toBuffer() });

    if (applicationCapabilities) {
        const capabilities = populateCapabilities(applicationCapabilities);
        writeValues.Capabilities = new common.ConfigValue({ version: writeVersion, value: capabilities.toBuffer(), mod_policy: modPolicy });
    }

    // Write Policy
    const writePolicies = generateWritePolicy(policyVersion, modPolicy);
github hyperledger / caliper / packages / caliper-fabric / lib / create-channel.js View on Github external
// Versioning
    const readVersion = 0;
    const writeVersion = 0;
    const appVersion = 1;
    const policyVersion = 0;

    // Build the readSet
    const readValues = {};
    readValues.Consortium = new common.ConfigValue();

    const readAppGroup = {};
    for (const mspId of mspIds) {
        readAppGroup[mspId] = new common.ConfigGroup();
    }
    const readGroups = {};
    readGroups.Application = new common.ConfigGroup({ groups: readAppGroup });

    const readSet = new common.ConfigGroup({ version: readVersion, groups: readGroups, values: readValues });

    // Build the writeSet (based on consortium name and passed Capabiliites)
    const modPolicy = 'Admins';
    const writeValues = {};

    const consortium = new common.Consortium({ name: consortiumName });
    writeValues.Consortium = new common.ConfigValue({ version: writeVersion, value: consortium.toBuffer() });

    if (applicationCapabilities) {
        const capabilities = populateCapabilities(applicationCapabilities);
        writeValues.Capabilities = new common.ConfigValue({ version: writeVersion, value: capabilities.toBuffer(), mod_policy: modPolicy });
    }

    // Write Policy
github hyperledger / caliper / packages / caliper-fabric / lib / create-channel.js View on Github external
const consortium = new common.Consortium({ name: consortiumName });
    writeValues.Consortium = new common.ConfigValue({ version: writeVersion, value: consortium.toBuffer() });

    if (applicationCapabilities) {
        const capabilities = populateCapabilities(applicationCapabilities);
        writeValues.Capabilities = new common.ConfigValue({ version: writeVersion, value: capabilities.toBuffer(), mod_policy: modPolicy });
    }

    // Write Policy
    const writePolicies = generateWritePolicy(policyVersion, modPolicy);

    // Write Application Groups
    const writeAppGroup = {};
    for (const mspId of mspIds) {
        writeAppGroup[mspId] = new common.ConfigGroup();
    }

    const writeGroups = {};
    writeGroups.Application = new common.ConfigGroup({ version: appVersion, groups: writeAppGroup, policies: writePolicies, mod_policy: modPolicy });

    const writeSet = new common.ConfigGroup({ version: writeVersion, groups: writeGroups, values: writeValues });

    // Now create the configUpdate and configUpdateEnv
    const configUpdate = new common.ConfigUpdate({ channel_id: channelName, read_set: readSet, write_set: writeSet});
    const configUpdateEnv= new common.ConfigUpdateEnvelope({ config_update: configUpdate.toBuffer(), signatures: [] });

    // Channel header
    const channelTimestamp = new google.protobuf.Timestamp({ seconds: Date.now()/1000, nanos: 0 }); // Date.now() is millis since 1970 epoch, we need seconds
    const channelEpoch = 0;
    const chHeader = new common.ChannelHeader({ type: common.HeaderType.CONFIG_UPDATE, version: channelVersion, timestamp: channelTimestamp, channel_id: channelName, epoch: channelEpoch });
github hyperledger / caliper / packages / caliper-fabric / lib / fabric.js View on Github external
_createChannelTxEnvelope(channelObject, channelName) {
        // Versioning
        const readVersion = 0;
        const writeVersion = 0;
        const appVersion = 1;
        const policyVersion = 0;

        // Build the readSet
        const readValues = {};
        readValues.Consortium = new common.ConfigValue();

        const readAppGroup = {};
        for (const mspId of channelObject.msps) {
            readAppGroup[mspId] = new common.ConfigGroup();
        }
        const readGroups = {};
        readGroups.Application = new common.ConfigGroup({ groups: readAppGroup });

        const readSet = new common.ConfigGroup({ version: readVersion, groups: readGroups, values: readValues });

        // Build the writeSet (based on consortium name and passed Capabiliites)
        const modPolicy = 'Admins';
        const writeValues = {};

        const consortium = new common.Consortium({ name: channelObject.consortium });
        writeValues.Consortium = new common.ConfigValue({ version: writeVersion, value: consortium.toBuffer() });

        if (channelObject.capabilities) {
            const capabilities = this._populateCapabilities(channelObject.capabilities);
            writeValues.Capabilities = new common.ConfigValue({ version: writeVersion, value: capabilities.toBuffer(), mod_policy: modPolicy });
github hyperledger / caliper / packages / caliper-fabric / lib / fabric.js View on Github external
const consortium = new common.Consortium({ name: channelObject.consortium });
        writeValues.Consortium = new common.ConfigValue({ version: writeVersion, value: consortium.toBuffer() });

        if (channelObject.capabilities) {
            const capabilities = this._populateCapabilities(channelObject.capabilities);
            writeValues.Capabilities = new common.ConfigValue({ version: writeVersion, value: capabilities.toBuffer(), mod_policy: modPolicy });
        }

        // Write Policy
        const writePolicies = this._generateWritePolicy(policyVersion, modPolicy);

        // Write Application Groups
        const writeAppGroup = {};
        for (const mspId of channelObject.msps) {
            writeAppGroup[mspId] = new common.ConfigGroup();
        }

        const writeGroups = {};
        writeGroups.Application = new common.ConfigGroup({ version: appVersion, groups: writeAppGroup, policies: writePolicies, mod_policy: modPolicy });

        const writeSet = new common.ConfigGroup({ version: writeVersion, groups: writeGroups, values: writeValues });

        // Now create the configUpdate and configUpdateEnv
        const configUpdate = new common.ConfigUpdate({ channel_id: channelName, read_set: readSet, write_set: writeSet});
        const configUpdateEnv= new common.ConfigUpdateEnvelope({ config_update: configUpdate.toBuffer(), signatures: [] });

        // Channel header
        const channelTimestamp = new google.protobuf.Timestamp({ seconds: Date.now()/1000, nanos: 0 }); // Date.now() is millis since 1970 epoch, we need seconds
        const channelEpoch = 0;
        const chHeader = new common.ChannelHeader({ type: common.HeaderType.CONFIG_UPDATE, version: channelObject.version, timestamp: channelTimestamp, channel_id: channelName, epoch: channelEpoch });
github hyperledger / caliper / packages / caliper-fabric / lib / fabric.js View on Github external
writeValues.Capabilities = new common.ConfigValue({ version: writeVersion, value: capabilities.toBuffer(), mod_policy: modPolicy });
        }

        // Write Policy
        const writePolicies = this._generateWritePolicy(policyVersion, modPolicy);

        // Write Application Groups
        const writeAppGroup = {};
        for (const mspId of channelObject.msps) {
            writeAppGroup[mspId] = new common.ConfigGroup();
        }

        const writeGroups = {};
        writeGroups.Application = new common.ConfigGroup({ version: appVersion, groups: writeAppGroup, policies: writePolicies, mod_policy: modPolicy });

        const writeSet = new common.ConfigGroup({ version: writeVersion, groups: writeGroups, values: writeValues });

        // Now create the configUpdate and configUpdateEnv
        const configUpdate = new common.ConfigUpdate({ channel_id: channelName, read_set: readSet, write_set: writeSet});
        const configUpdateEnv= new common.ConfigUpdateEnvelope({ config_update: configUpdate.toBuffer(), signatures: [] });

        // Channel header
        const channelTimestamp = new google.protobuf.Timestamp({ seconds: Date.now()/1000, nanos: 0 }); // Date.now() is millis since 1970 epoch, we need seconds
        const channelEpoch = 0;
        const chHeader = new common.ChannelHeader({ type: common.HeaderType.CONFIG_UPDATE, version: channelObject.version, timestamp: channelTimestamp, channel_id: channelName, epoch: channelEpoch });

        // Common header
        const header = new common.Header({ channel_header: chHeader.toBuffer() });

        // Form the payload header/data
        const payload = new common.Payload({ header: header, data: configUpdateEnv.toBuffer() });