mc/byzantine.js
function getCoordinators(conn, hp, phase, cb){
    hp = parseInt(hp);
    phase = parseInt(phase);
    var pIndex = Math.abs(hp-phase+999)%constants.TOTAL_COORDINATORS;
    if (assocByzantinePhase[hp] && assocByzantinePhase[hp].roundIndex && assocByzantinePhase[hp].witnesses){
        return cb(null, assocByzantinePhase[hp].witnesses[pIndex], assocByzantinePhase[hp].roundIndex, assocByzantinePhase[hp].witnesses);
    }
    if(!validationUtils.isPositiveInteger(hp))
        return cb("param hp is not a positive integer:" + hp);
    if(!validationUtils.isNonnegativeInteger(phase))
        return cb("param phase is not a positive integer:" + phase);
    var conn = conn || db;
    round.getRoundIndexByNewMci(conn, hp, function(roundIndex){
        if(roundIndex === -1)
            return cb("have not get the last mci yet ");
        round.getWitnessesByRoundIndex(conn, roundIndex, function(witnesses){
            if(!assocByzantinePhase[hp] || typeof assocByzantinePhase[hp] === 'undefined' || Object.keys(assocByzantinePhase[hp]).length === 0){
                assocByzantinePhase[hp] = {};
                assocByzantinePhase[hp].roundIndex = roundIndex;
                assocByzantinePhase[hp].witnesses = witnesses;
                assocByzantinePhase[hp].phase = {};
                assocByzantinePhase[hp].decision = {};    
            }            
            cb(null, witnesses[pIndex], roundIndex, witnesses);
        });        
    });
}
function getCoordinators(conn, hp, phase, cb){
    hp = parseInt(hp);
    phase = parseInt(phase);
    var pIndex = Math.abs(hp-phase+999)%constants.TOTAL_COORDINATORS;
    if (assocByzantinePhase[hp] && assocByzantinePhase[hp].roundIndex && assocByzantinePhase[hp].witnesses){
        return cb(null, assocByzantinePhase[hp].witnesses[pIndex], assocByzantinePhase[hp].roundIndex, assocByzantinePhase[hp].witnesses);
    }
    if(!validationUtils.isPositiveInteger(hp))
        return cb("param hp is not a positive integer:" + hp);
    if(!validationUtils.isNonnegativeInteger(phase))
        return cb("param phase is not a positive integer:" + phase);
    var conn = conn || db;
    round.getRoundIndexByNewMci(conn, hp, function(roundIndex){
        if(roundIndex === -1)
            return cb("have not get the last mci yet ");
        round.getWitnessesByRoundIndex(conn, roundIndex, function(witnesses){
            if(!assocByzantinePhase[hp] || typeof assocByzantinePhase[hp] === 'undefined' || Object.keys(assocByzantinePhase[hp]).length === 0){
                assocByzantinePhase[hp] = {};
                assocByzantinePhase[hp].roundIndex = roundIndex;
                assocByzantinePhase[hp].witnesses = witnesses;
                assocByzantinePhase[hp].phase = {};
                assocByzantinePhase[hp].decision = {};    
            }            
            cb(null, witnesses[pIndex], roundIndex, witnesses);
        });        
    });
}
function getCoordinators ( conn , hp , phase , cb ) { hp = parseInt ( hp ) ; phase = parseInt ( phase ) ; var pIndex = Math . abs ( hp - phase + 999 ) % constants . TOTAL_COORDINATORS ; if ( assocByzantinePhase [ hp ] && assocByzantinePhase [ hp ] . roundIndex && assocByzantinePhase [ hp ] . witnesses ) { return cb ( null , assocByzantinePhase [ hp ] . witnesses [ pIndex ] , assocByzantinePhase [ hp ] . roundIndex , assocByzantinePhase [ hp ] . witnesses ) ; } if ( ! validationUtils . isPositiveInteger ( hp ) ) return cb ( "param hp is not a positive integer:" + hp ) ; if ( ! validationUtils . isNonnegativeInteger ( phase ) ) return cb ( "param phase is not a positive integer:" + phase ) ; var conn = conn || db ; round . getRoundIndexByNewMci ( conn , hp , function ( roundIndex ) { if ( roundIndex === - 1 ) return cb ( "have not get the last mci yet " ) ; round . getWitnessesByRoundIndex ( conn , roundIndex , function ( witnesses ) { if ( ! assocByzantinePhase [ hp ] || typeof assocByzantinePhase [ hp ] === 'undefined' || Object . keys ( assocByzantinePhase [ hp ] ) . length === 0 ) { assocByzantinePhase [ hp ] = { } ; assocByzantinePhase [ hp ] . roundIndex = roundIndex ; assocByzantinePhase [ hp ] . witnesses = witnesses ; assocByzantinePhase [ hp ] . phase = { } ; assocByzantinePhase [ hp ] . decision = { } ; } cb ( null , witnesses [ pIndex ] , roundIndex , witnesses ) ; } ) ; } ) ; }
public function begin 
Get proposer witnesses and round index by hp and phase

@param	{obj}	    conn      if conn is null, use db query, otherwise use conn.
@param   {Integer}   hp
@param   {Integer}   phase
@param   {function}	callback( err, proposer, roundIndex, witnesses ) callback function
public function begin Get proposer witnesses and round index by hp and phase