does puff help?

This commit is contained in:
Mark Nadal 2019-09-17 03:15:13 -07:00
parent 3953c17130
commit 1f0d0d62b0

15
gun.js
View File

@ -1954,6 +1954,7 @@
;USE(function(module){ ;USE(function(module){
var Type = USE('../type'); var Type = USE('../type');
var puff = (typeof setImmediate !== "undefined")? setImmediate : setTimeout;
function Mesh(root){ function Mesh(root){
var mesh = function(){}; var mesh = function(){};
@ -1972,10 +1973,16 @@
if('[' === tmp){ if('[' === tmp){
try{msg = JSON.parse(raw);}catch(e){opt.log('DAM JSON parse error', e)} try{msg = JSON.parse(raw);}catch(e){opt.log('DAM JSON parse error', e)}
if(!msg){ return } if(!msg){ return }
var i = 0, m; (function go(){
while(m = msg[i++]){ var S = +new Date; // STATS!
mesh.hear(m, peer); var m, c = 100; // hardcoded for now?
} while(c-- && (m = msg.shift())){
mesh.hear(m, peer);
}
(mesh.hear.long || (mesh.hear.long = [])).push(+new Date - S);
if(!msg.length){ return }
puff(go, 0);
}());
return; return;
} }
if('{' === tmp || (Type.obj.is(raw) && (msg = raw))){ if('{' === tmp || (Type.obj.is(raw) && (msg = raw))){