mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
fix peer sharing
This commit is contained in:
parent
8f6322efc0
commit
5efedd7308
28
lib/axe.js
28
lib/axe.js
@ -132,9 +132,33 @@ function start(root){
|
||||
axe.up[p.pid] = p; // update same to be same.
|
||||
return;
|
||||
}
|
||||
if(!peer.url){ return }
|
||||
axe.up[peer.pid] = peer;
|
||||
};
|
||||
root.on('hi', function(peer){
|
||||
this.to.next(peer);
|
||||
if(!peer.url){ return }
|
||||
axe.up[peer.pid || peer.id] = peer;
|
||||
});
|
||||
}());
|
||||
|
||||
;(function(){ // OPT MODULE
|
||||
mesh.hear['opt'] = function(msg, peer){
|
||||
if(msg.ok){ return }
|
||||
var tmp = msg.opt;
|
||||
if(!tmp){ return }
|
||||
tmp = tmp.peers;
|
||||
if(!tmp || 'string' != typeof tmp){ return }
|
||||
if(axe.up[tmp] || 6 <= Object.keys(axe.up).length){ return }
|
||||
mesh.hi({id: tmp, url: tmp, retry: 9});
|
||||
if(peer){ mesh.say({dam: 'opt', ok: 1, '@': msg['#']}, peer) }
|
||||
}
|
||||
/*setInterval(function(tmp){
|
||||
if(!(tmp = at.stats && at.stats.stay)){ return }
|
||||
(tmp.axe = tmp.axe || {}).up = Object.keys(axe.up||{});
|
||||
},1000 * 60)
|
||||
setTimeout(function(tmp){
|
||||
if(!(tmp = at.stats && at.stats.stay)){ return }
|
||||
Gun.obj.map((tmp.axe||{}).up, function(url){ mesh.hear.opt({opt: {peers: url}}) })
|
||||
},1000);*/
|
||||
}());
|
||||
|
||||
;(function(){ // THIS IS THE MOB MODULE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user