mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
debug mode print mem & peers
This commit is contained in:
parent
c10002c2ac
commit
74699f64f8
20
lib/debug.js
20
lib/debug.js
@ -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
27
lib/evict.js
Normal 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){
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
*/
|
||||
});
|
||||
}());
|
Loading…
x
Reference in New Issue
Block a user