lib/gossip/damper.js
function createDampReqHandler(addr) {
        var start = self.Date.now();
        return function onDampReq(err, res) {
            var timing = self.Date.now() - start;
            self.ringpop.stat('timing', 'protocol.damp-req', timing);

            // Prevents double-callback
            if (typeof callback !== 'function') {
                return;
            }

            numPendingReqs--;

            if (err) {
                errors.push(err);
            } else {
                // Enrich the result with the addr of the damp
                // req member for reporting purposes.
                res.dampReqAddr = addr;
                res.timing = timing;
                results.push(res);
            }

            // The first rVal requests will be reported.
            if (results.length >= rVal) {
                callback(null, results);
                callback = null;
                return;
            }

            if (numPendingReqs < rVal - results.length) {
                callback(UnattainableRValError({
                    flappers: flapperAddrs,
                    rVal: rVal,
                    errors: errors
                }));
                callback = null;
                return;
            }
        };
    }
function createDampReqHandler(addr) {
        var start = self.Date.now();
        return function onDampReq(err, res) {
            var timing = self.Date.now() - start;
            self.ringpop.stat('timing', 'protocol.damp-req', timing);

            // Prevents double-callback
            if (typeof callback !== 'function') {
                return;
            }

            numPendingReqs--;

            if (err) {
                errors.push(err);
            } else {
                // Enrich the result with the addr of the damp
                // req member for reporting purposes.
                res.dampReqAddr = addr;
                res.timing = timing;
                results.push(res);
            }

            // The first rVal requests will be reported.
            if (results.length >= rVal) {
                callback(null, results);
                callback = null;
                return;
            }

            if (numPendingReqs < rVal - results.length) {
                callback(UnattainableRValError({
                    flappers: flapperAddrs,
                    rVal: rVal,
                    errors: errors
                }));
                callback = null;
                return;
            }
        };
    }
function createDampReqHandler ( addr ) { var start = self . Date . now ( ) ; return function onDampReq ( err , res ) { var timing = self . Date . now ( ) - start ; self . ringpop . stat ( 'timing' , 'protocol.damp-req' , timing ) ; // Prevents double-callback if ( typeof callback !== 'function' ) { return ; } numPendingReqs -- ; if ( err ) { errors . push ( err ) ; } else { // Enrich the result with the addr of the damp // req member for reporting purposes. res . dampReqAddr = addr ; res . timing = timing ; results . push ( res ) ; } // The first rVal requests will be reported. if ( results . length >= rVal ) { callback ( null , results ) ; callback = null ; return ; } if ( numPendingReqs < rVal - results . length ) { callback ( UnattainableRValError ( { flappers : flapperAddrs , rVal : rVal , errors : errors } ) ) ; callback = null ; return ; } } ; }
Accumulate responses until rVal is satisfied or is impossible to satisfy because too many error responses.
Accumulate responses until rVal is satisfied or is impossible to satisfy because too many error responses .