lib/emulator_market.js
function cancelBets() {
        // check request bets list
        var error;
        for ( var i = 0; i < req.request.bets.length; ++i) {
            var desc = req.request.bets[i];
            error = checkCancelBetItem(self, desc);
            // console.log('EMU bet', desc, "error", error);
            if (error)
                break;
        }
        if (error) {
            res.response.errorCode = 'MARKET_IDS_DONT_MATCH';
            cb(null, res);
            return;
        }

        // cancel bets
        res.response.errorCode = 'OK';
        res.response.betResults = [];
        for ( var i = 0; i < req.request.bets.length; ++i) {
            var betId = req.request.bets[i].betId;
            console.log('EMU: cancel id=', betId);
            var bet = self.bets[betId];

            // do cancel work
            var result = bet.cancel();

            var resItem = {
                betId : bet.betId,
                resultCode : result.code,
                sizeCancelled : result.sizeCancelled,
                sizeMatched : result.sizeMatched,
                success : result.success
            };

            res.response.betResults.push(resItem);
        }

        // cancelBets was OK
        cb(null, res);
    }
function cancelBets() {
        // check request bets list
        var error;
        for ( var i = 0; i < req.request.bets.length; ++i) {
            var desc = req.request.bets[i];
            error = checkCancelBetItem(self, desc);
            // console.log('EMU bet', desc, "error", error);
            if (error)
                break;
        }
        if (error) {
            res.response.errorCode = 'MARKET_IDS_DONT_MATCH';
            cb(null, res);
            return;
        }

        // cancel bets
        res.response.errorCode = 'OK';
        res.response.betResults = [];
        for ( var i = 0; i < req.request.bets.length; ++i) {
            var betId = req.request.bets[i].betId;
            console.log('EMU: cancel id=', betId);
            var bet = self.bets[betId];

            // do cancel work
            var result = bet.cancel();

            var resItem = {
                betId : bet.betId,
                resultCode : result.code,
                sizeCancelled : result.sizeCancelled,
                sizeMatched : result.sizeMatched,
                success : result.success
            };

            res.response.betResults.push(resItem);
        }

        // cancelBets was OK
        cb(null, res);
    }
function cancelBets ( ) { // check request bets list var error ; for ( var i = 0 ; i < req . request . bets . length ; ++ i ) { var desc = req . request . bets [ i ] ; error = checkCancelBetItem ( self , desc ) ; // console.log('EMU bet', desc, "error", error); if ( error ) break ; } if ( error ) { res . response . errorCode = 'MARKET_IDS_DONT_MATCH' ; cb ( null , res ) ; return ; } // cancel bets res . response . errorCode = 'OK' ; res . response . betResults = [ ] ; for ( var i = 0 ; i < req . request . bets . length ; ++ i ) { var betId = req . request . bets [ i ] . betId ; console . log ( 'EMU: cancel id=' , betId ) ; var bet = self . bets [ betId ] ; // do cancel work var result = bet . cancel ( ) ; var resItem = { betId : bet . betId , resultCode : result . code , sizeCancelled : result . sizeCancelled , sizeMatched : result . sizeMatched , success : result . success } ; res . response . betResults . push ( resItem ) ; } // cancelBets was OK cb ( null , res ) ; }
cancel bets, the function is delayed to simulate slow network
cancel bets the function is delayed to simulate slow network