How to use the fabric-client/lib/Orderer.js function in fabric-client

To help you get started, we’ve selected a few fabric-client 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 / composer-tools / packages / fabric-dev-servers / fabric-scripts / hlfv1-node / hlfv1 / join-channel.js View on Github external
function joinChannel(org) {
    console.log(util.format('Calling peers in organization "%s" to join the channel'));

    //
    // Create and configure the test chain
    //
    let client = new hfc();
    let chain = client.newChain(channel);
    if (useTls) {
        let caRootsPath = ORGS.orderer.tls_cacerts;
        let data = fs.readFileSync(path.join(__dirname, caRootsPath));
        let caroots = Buffer.from(data).toString();

        chain.addOrderer(
            new Orderer(
                ORGS.orderer.url,
                {
                    'pem': caroots,
                    'ssl-target-name-override': ORGS.orderer['server-hostname']
                }
            )
        );
    }
    else {
        chain.addOrderer(new Orderer(ORGS.orderer));
    }

    let targets = [];
    for (let key in ORGS[org]) {
        if (ORGS[org].hasOwnProperty(key)) {
            if (key.indexOf('peer') === 0) {
github IBM-Blockchain-Archive / marbles / utils / fc_wrangler / parts / enrollment.js View on Github external
}).then(function (submitter) {

			channel.addOrderer(new Orderer(options.orderer_url, options.orderer_tls_opts));

			channel.addPeer(new Peer(options.peer_urls[0], options.peer_tls_opts));
			logger.debug('added peer', options.peer_urls[0]);

			// --- Success --- //
			logger.debug('[fcw] Successfully got enrollment ' + options.uuid);
			if (cb) cb(null, { client: client, channel: channel, submitter: submitter });
			return;

		}).catch(function (err) {
github hyperledger / fabric / test / tools / PTE / pte-execRequest.js View on Github external
if (TLS.toUpperCase() == 'ENABLED') {
        var caRootsPath = ORGS['orderer'][ordererID].tls_cacerts;
        let data = fs.readFileSync(caRootsPath);
        let caroots = Buffer.from(data).toString();

        chain.addOrderer(
            new Orderer(
                ORGS['orderer'][ordererID].url,
                {
                    'pem': caroots,
                    'ssl-target-name-override': ORGS['orderer'][ordererID]['server-hostname']
                }
            )
        );
    } else {
        chain.addOrderer( new Orderer(ORGS['orderer'][ordererID].url));
        console.log('[Nid:id:chan:org=%d:%d:%s:%s channelAddOrderer] orderer url: ', Nid, pid, channelName, org, ORGS['orderer'][ordererID].url);
    }
    console.log('[Nid:id:chan:org=%d:%d:%s:%s channelAddOrderer] orderer in the chain: ', Nid, pid, channelName, org, chain.getOrderers());
}
github hyperledger / fabric-sdk-node / test / unit / orderer.js View on Github external
test('orderer bad address test', function(t) {
	testUtil.resetDefaults();

	try {
		new Orderer('xxxxx');
		t.fail('Orderer allowed setting a bad URL.');
	}
	catch(err) {
		t.pass('Orderer did not allow setting bad URL.');
	}
	t.end();
});
github hyperledger / fabric / test / tools / PTE / pte-execRequest.js View on Github external
function channelAddOrderer(chain, client, org) {
    var ordererID = ORGS[org].ordererID;
    console.log('[Nid:id:chan:org:ordererID=%d:%d:%s:%s:%s channelAddOrderer] chain name: ', Nid, pid, channelName, org, ordererID, chain.getName());
    if (TLS.toUpperCase() == 'ENABLED') {
        var caRootsPath = ORGS['orderer'][ordererID].tls_cacerts;
        let data = fs.readFileSync(caRootsPath);
        let caroots = Buffer.from(data).toString();

        chain.addOrderer(
            new Orderer(
                ORGS['orderer'][ordererID].url,
                {
                    'pem': caroots,
                    'ssl-target-name-override': ORGS['orderer'][ordererID]['server-hostname']
                }
            )
        );
    } else {
        chain.addOrderer( new Orderer(ORGS['orderer'][ordererID].url));
        console.log('[Nid:id:chan:org=%d:%d:%s:%s channelAddOrderer] orderer url: ', Nid, pid, channelName, org, ORGS['orderer'][ordererID].url);
    }
    console.log('[Nid:id:chan:org=%d:%d:%s:%s channelAddOrderer] orderer in the chain: ', Nid, pid, channelName, org, chain.getOrderers());
}
github hyperledger / fabric-sdk-node / test / unit / orderer.js View on Github external
test('orderer unknown address test', function(t) {
	var client = new Orderer('grpc://127.0.0.1:51006');

	client.sendBroadcast('some data')
		.then(
			function() {
				t.fail('Should have noticed a bad address.');
				t.end();
			},
			function(err) {
				t.equal(err.message, 'Failed to connect before the deadline',
					'sendBroadcast to unreachable orderer should response connection failed');
				t.pass('Successfully found bad address!');
				t.end();
			}
		).catch(function(err) {
			t.fail('Caught Error: should not be here if we defined promise error function: '
		+ err);
github hyperledger / fabric-sdk-node / test / unit / channel.js View on Github external
() => {
			const orderer = new Orderer('grpc://somehost.com:1234');
			_channel.addOrderer(orderer);
		},
		/^DuplicateOrderer: Orderer/,
github hyperledger / fabric-sdk-node / test / unit / channel.js View on Github external
() => {
			channel._getOrderer('bad');
		},
		/Orderer bad not assigned to the channel/,
		'Channel _getOrderer test: using bad name and no orderers assigned to channel'
	);

	t.throws(
		() => {
			channel._getOrderer({});
		},
		/Orderer is not a valid orderer object instance/,
		'Channel _getOrderer test: using bad object and no orderers assigned to channel'
	);

	const orderer = new Orderer('grpc://somehost.com:1234');
	t.doesNotThrow(
		() => {
			const test_orderer = channel._getOrderer(orderer);
			t.equal(test_orderer.getName(), 'somehost.com:1234', 'Checking able to get correct name');
		},
		'Channel _getOrderer: checking able to find orderer by name'
	);

	channel.addOrderer(orderer);
	t.doesNotThrow(
		() => {
			channel._getOrderer('somehost.com:1234');
		},
		'Channel _getOrderer: checking able to find orderer by name'
	);
github hyperledger / fabric-sdk-node / examples / balance-transfer / invoke.js View on Github external
function init() {
	chain = client.newChain(config.chainName);
	chain.addOrderer(new Orderer(config.orderer.orderer_url));
	eventhub = new EventHub();
	eventhub.setPeerAddr(config.events[0].event_url);
	eventhub.connect();
	for (var i = 0; i < config.peers.length; i++) {
		chain.addPeer(new Peer(config.peers[i].peer_url));
	}
}
github y12studio / dltdojo / dockerfiles / triple-chain / v1 / deploy.js View on Github external
function init () {
  chain = client.newChain(config.chainName)
  chain.addOrderer(new Orderer(config.orderer.orderer_url))
  eventhub = new EventHub()
  eventhub.setPeerAddr(config.events[0].event_url)
  eventhub.connect()
  for (var i = 0; i < config.peers.length; i++) {
    chain.addPeer(new Peer(config.peers[i].peer_url))
  }
}