src/quorum/quorum.js
/**
     * Invoke the given chaincode according to the specified options. Multiple transactions will be generated according to the length of args.
     * @param {object} context The Quorum context returned by {getContext}.
     * @param {string} contractID The name of the chaincode.
     * @param {string} contractVer The version of the chaincode.
     * @param {Array} args Array of JSON formatted arguments for transaction(s). Each element containts arguments (including the function name) passing to the chaincode. JSON attribute named transaction_type is used by default to specify the function name. If the attribute does not exist, the first attribute will be used as the function name.
     * @param {number} timeout The timeout to set for the execution in seconds.
     * @return {Promise<object>} The promise for the result of the execution.
     */
Invoke the given chaincode according to the specified options. Multiple transactions will be generated according to the length of args.
@param {object} context The Quorum context returned by {getContext}.
@param {string} contractID The name of the chaincode.
@param {string} contractVer The version of the chaincode.
@param {Array} args Array of JSON formatted arguments for transaction(s). Each element containts arguments (including the function name) passing to the chaincode. JSON attribute named transaction_type is used by default to specify the function name. If the attribute does not exist, the first attribute will be used as the function name.
@param {number} timeout The timeout to set for the execution in seconds.
@return {Promise} The promise for the result of the execution.
Invoke the given chaincode according to the specified options . Multiple transactions will be generated according to the length of args . @param { object } context The Quorum context returned by { getContext } . @param { string } contractID The name of the chaincode . @param { string } contractVer The version of the chaincode . @param { Array } args Array of JSON formatted arguments for transaction ( s ) . Each element containts arguments ( including the function name ) passing to the chaincode . JSON attribute named transaction_type is used by default to specify the function name . If the attribute does not exist the first attribute will be used as the function name . @param { number } timeout The timeout to set for the execution in seconds . @return { Promise } The promise for the result of the execution .
invokeSmartContract(context, contractID, contractVer, args, timeout) {
        const web3 = context.my_web3;
        let address = contractID[0];
        let abi = contractID[1];
        let contractInstance = new web3.eth.Contract(abi, address);
        let self = this;
        return web3.eth.getAccounts()
            .then((accounts)=>{
                let acc_id = Math.floor(context.clientIdx / context.web3s.length) % accounts.length;
                let promises = [];
                let from_acc = accounts[acc_id];
                args.forEach((item, index)=>{
                    try {
                        let simpleArgs = [];
                        let func;
                        for(let key in item) {
                            if(key === 'transaction_type') {
                                func = item[key].toString();
                            }
                            else {
                                simpleArgs.push(item[key]);
                            }
                        }
                        promises.push(self.sendTxn(contractInstance, func, simpleArgs, from_acc));
                    } catch(err) {
                        let badResult = new TxStatus('artifact');
                        badResult.SetStatusFail();
                        badResult.SetVerification(true);
                        promises.push(Promise.resolve(badResult));
                    }
                });
                return Promise.all(promises);
            });
    }
invokeSmartContract ( context , contractID , contractVer , args , timeout ) { const web3 = context . my_web3 ; let address = contractID [ 0 ] ; let abi = contractID [ 1 ] ; let contractInstance = new web3 . eth . Contract ( abi , address ) ; let self = this ; return web3 . eth . getAccounts ( ) . then ( ( accounts ) => { let acc_id = Math . floor ( context . clientIdx / context . web3s . length ) % accounts . length ; let promises = [ ] ; let from_acc = accounts [ acc_id ] ; args . forEach ( ( item , index ) => { try { let simpleArgs = [ ] ; let func ; for ( let key in item ) { if ( key === 'transaction_type' ) { func = item [ key ] . toString ( ) ; } else { simpleArgs . push ( item [ key ] ) ; } } promises . push ( self . sendTxn ( contractInstance , func , simpleArgs , from_acc ) ) ; } catch ( err ) { let badResult = new TxStatus ( 'artifact' ) ; badResult . SetStatusFail ( ) ; badResult . SetVerification ( true ) ; promises . push ( Promise . resolve ( badResult ) ) ; } } ) ; return Promise . all ( promises ) ; } ) ; }
Invoke the given chaincode according to the specified options.
Invoke the given chaincode according to the specified options .
// let node_url = this.nodes_info[context.clientIdx % this.nodes_info.length].url; // const web3 = new Web3(new Web3.providers.HttpProvider(node_url)); // let contractInstance = web3.eth.contract(abi).at(address); // console.log("Selected Account and Idx: ", accounts[acc_id], acc_id) // let bef = Date.now();