src/comm/client/local-client.js
/**
 * Calculate realtime transaction statistics and send the txUpdated message
 */
Calculate realtime transaction statistics and send the txUpdated message
Calculate realtime transaction statistics and send the txUpdated message
function txUpdate() {
    let newNum = txNum - txLastNum;
    txLastNum += newNum;
    let newResults = results.slice(0);
    results = [];
    if(newResults.length === 0 && newNum === 0) {
        return;
    }
    let newQueryTxnStatuses = [];
    let newInvokeTxnStatuses = [];
    newResults.forEach(function(newTxnStatus) {
        if (newTxnStatus.Get("operation") === "query") {
            newQueryTxnStatuses.push(newTxnStatus);
        } else if (newTxnStatus.Get("operation") === "invoke") {
            newInvokeTxnStatuses.push(newTxnStatus);
        } else {
            console.log("Unrecognized txn operation type");
        }
    });
    let newQueryStats;
    if (newQueryTxnStatuses.length === 0) {
        newQueryStats = bc.createNullDefaultTxStats();
    } else {
        newQueryStats = blockchain.getDefaultTxStats(newQueryTxnStatuses, true);
    }
    let newInvokeStats;
    let newDetailedDelayStats;
    if (newInvokeTxnStatuses.length === 0) {
        newInvokeStats = bc.createNullDefaultTxStats();
        newDetailedDelayStats = bc.createNullDetailedDelayStats();
    } else {
        newInvokeStats = blockchain.getDefaultTxStats(newInvokeTxnStatuses, true);
        newDetailedDelayStats = blockchain.getDetailedDelayStats(newInvokeTxnStatuses, false)
    }
    let newStats;
    if(newResults.length === 0) {
        newStats = bc.createNullDefaultTxStats();
    } else {
        newStats = blockchain.getDefaultTxStats(newResults, true);
    }
    process.send({type: 'txUpdated', data: {submitted: newNum, committed: newStats}});
    if (queryStats.length === 0) {
        switch (trimType) {
        case 0: 
            queryStats[0] = newQueryStats;
            break;
        case 1: 
            if (trim < (Date.now() - startTime)/1000) {
                queryStats[0] = newQueryStats;
            }
            break;
        case 2: 
            if (trim < 0) {
                queryStats[0] = newQueryStats;
            }            
            break;
        }
    } else {
        queryStats[1] = newQueryStats;
        bc.mergeDefaultTxStats(queryStats);
    }
    if (invokeStats.length === 0) {
        switch (trimType) {
        case 0: 
            invokeStats[0] = newInvokeStats;
            detailedDelayStats[0] = newDetailedDelayStats;
            break;
        case 1: 
            if (trim < (Date.now() - startTime)/1000) {
                invokeStats[0] = newInvokeStats;
                detailedDelayStats[0] = newDetailedDelayStats;
            }
            break;
        case 2: 
            if (trim < 0) {
                invokeStats[0] = newInvokeStats;
                detailedDelayStats[0] = newDetailedDelayStats;
            }
            break;
        }
    } else {
        invokeStats[1] = newInvokeStats;
        detailedDelayStats[1] = newDetailedDelayStats;
        bc.mergeDefaultTxStats(invokeStats);
        bc.mergeDetailedDelayStats(detailedDelayStats);
    }
    if (resultStats.length === 0) {
        switch (trimType) {
        case 0: 
            resultStats[0] = newStats;
            break;
        case 1: 
            if (trim < (Date.now() - startTime)/1000) {
                resultStats[0] = newStats;
            }
            break;
        case 2: 
            if (trim < 0) {
                resultStats[0] = newStats;
            } else {
                trim -= newResults.length;
            }
            break;
        }
    } else {
        resultStats[1] = newStats;
        bc.mergeDefaultTxStats(resultStats);
    }
}
function txUpdate ( ) { let newNum = txNum - txLastNum ; txLastNum += newNum ; let newResults = results . slice ( 0 ) ; results = [ ] ; if ( newResults . length === 0 && newNum === 0 ) { return ; } let newQueryTxnStatuses = [ ] ; let newInvokeTxnStatuses = [ ] ; newResults . forEach ( function ( newTxnStatus ) { if ( newTxnStatus . Get ( "operation" ) === "query" ) { newQueryTxnStatuses . push ( newTxnStatus ) ; } else if ( newTxnStatus . Get ( "operation" ) === "invoke" ) { newInvokeTxnStatuses . push ( newTxnStatus ) ; } else { console . log ( "Unrecognized txn operation type" ) ; } } ) ; let newQueryStats ; if ( newQueryTxnStatuses . length === 0 ) { newQueryStats = bc . createNullDefaultTxStats ( ) ; } else { newQueryStats = blockchain . getDefaultTxStats ( newQueryTxnStatuses , true ) ; } let newInvokeStats ; let newDetailedDelayStats ; if ( newInvokeTxnStatuses . length === 0 ) { newInvokeStats = bc . createNullDefaultTxStats ( ) ; newDetailedDelayStats = bc . createNullDetailedDelayStats ( ) ; } else { newInvokeStats = blockchain . getDefaultTxStats ( newInvokeTxnStatuses , true ) ; newDetailedDelayStats = blockchain . getDetailedDelayStats ( newInvokeTxnStatuses , false ) } let newStats ; if ( newResults . length === 0 ) { newStats = bc . createNullDefaultTxStats ( ) ; } else { newStats = blockchain . getDefaultTxStats ( newResults , true ) ; } process . send ( { type : 'txUpdated' , data : { submitted : newNum , committed : newStats } } ) ; if ( queryStats . length === 0 ) { switch ( trimType ) { case 0 : queryStats [ 0 ] = newQueryStats ; break ; case 1 : if ( trim < ( Date . now ( ) - startTime ) / 1000 ) { queryStats [ 0 ] = newQueryStats ; } break ; case 2 : if ( trim < 0 ) { queryStats [ 0 ] = newQueryStats ; } break ; } } else { queryStats [ 1 ] = newQueryStats ; bc . mergeDefaultTxStats ( queryStats ) ; } if ( invokeStats . length === 0 ) { switch ( trimType ) { case 0 : invokeStats [ 0 ] = newInvokeStats ; detailedDelayStats [ 0 ] = newDetailedDelayStats ; break ; case 1 : if ( trim < ( Date . now ( ) - startTime ) / 1000 ) { invokeStats [ 0 ] = newInvokeStats ; detailedDelayStats [ 0 ] = newDetailedDelayStats ; } break ; case 2 : if ( trim < 0 ) { invokeStats [ 0 ] = newInvokeStats ; detailedDelayStats [ 0 ] = newDetailedDelayStats ; } break ; } } else { invokeStats [ 1 ] = newInvokeStats ; detailedDelayStats [ 1 ] = newDetailedDelayStats ; bc . mergeDefaultTxStats ( invokeStats ) ; bc . mergeDetailedDelayStats ( detailedDelayStats ) ; } if ( resultStats . length === 0 ) { switch ( trimType ) { case 0 : resultStats [ 0 ] = newStats ; break ; case 1 : if ( trim < ( Date . now ( ) - startTime ) / 1000 ) { resultStats [ 0 ] = newStats ; } break ; case 2 : if ( trim < 0 ) { resultStats [ 0 ] = newStats ; } else { trim -= newResults . length ; } break ; } } else { resultStats [ 1 ] = newStats ; bc . mergeDefaultTxStats ( resultStats ) ; } }
Calculate realtime transaction statistics and send the txUpdated message
Calculate realtime transaction statistics and send the txUpdated message
// results is an array of txnstatus // no trim // based on duration // based on number // no trim // based on duration // based on number // no trim // based on duration // based on number