debug mode print mem & peers

This commit is contained in:
Mark Nadal 2018-05-15 11:02:18 -07:00
parent c10002c2ac
commit 74699f64f8
2 changed files with 45 additions and 2 deletions

View File

@ -1,13 +1,29 @@
;(function(){
if('debug' !== process.env.GUN_ENV){ return }
var db = {};
console.log("start :)");
global.DEBUG = 1;
setInterval(function(){
var mem = process.memoryUsage();
var used = mem.heapUsed / 1024 / 1024;
var print = '';
used = used.toFixed(1);
console.log(used, 'MB');
}, 1000);
print += used +' MB. '
if(db.root){
db.concurrency = Object.keys(db.peers||{}).length;
print += db.concurrency +' peers. ';
}
console.log(print);
}, 2500);
var Gun = require('../gun');
Gun.on('opt', function(root){
this.to.next(root);
if(root.once){ return }
db.root = root;
db.peers = root.opt.peers;
})
}());

27
lib/evict.js Normal file
View File

@ -0,0 +1,27 @@
;(function(){
var Gun = (typeof window !== 'undefined')? window.Gun : require('../gun');
var LRU = 1, empty = {}, u;
Gun.on('opt', function(root){
this.to.next(root);
if(root.once){ return }
root.on('get', function(msg){
})
/*
root.on('in', function(msg){
this.to.next(msg);
if(msg.get){
return;
}
Gun.graph.is(msg, function(node, soul){
var meta = (root.next||empty)[soul];
if(!meta){ return }
Gun.node.is(node, function(data, key){
});
});
});
*/
});
}());