mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
unbuild fixes/updates
This commit is contained in:
parent
ced1e20ecc
commit
3277ba4127
2
gun.min.js
vendored
2
gun.min.js
vendored
File diff suppressed because one or more lines are too long
@ -163,7 +163,6 @@ function Mesh(root){
|
||||
});
|
||||
}
|
||||
mesh.bye = function(peer){
|
||||
Type.obj.del(opt.peers, peer.id); // assume if peer.url then reconnect
|
||||
root.on('bye', peer);
|
||||
var tmp = +(new Date); tmp = (tmp - (peer.met||tmp));
|
||||
mesh.bye.time = ((mesh.bye.time || tmp) + tmp) / 2;
|
||||
@ -190,6 +189,14 @@ function Mesh(root){
|
||||
root.on('out', mesh.say);
|
||||
});
|
||||
|
||||
root.on('bye', function(peer, tmp){
|
||||
peer = opt.peers[peer.id || peer] || peer;
|
||||
this.to.next(peer);
|
||||
peer.bye? peer.bye() : (tmp = peer.wire) && tmp.close && tmp.close();
|
||||
Type.obj.del(opt.peers, peer.id);
|
||||
peer.wire = null;
|
||||
});
|
||||
|
||||
var gets = {};
|
||||
root.on('bye', function(peer, tmp){ this.to.next(peer);
|
||||
if(!(tmp = peer.url)){ return } gets[tmp] = true;
|
||||
@ -239,7 +246,6 @@ function Mesh(root){
|
||||
}());
|
||||
|
||||
var empty = {}, ok = true, u;
|
||||
Object.keys = Object.keys || function(o){ return map(o, function(v,k,t){t(k)}) }
|
||||
|
||||
try{ module.exports = Mesh }catch(e){}
|
||||
|
||||
|
@ -30,11 +30,7 @@ Gun.on('opt', function(root){
|
||||
reconnect(peer);
|
||||
};
|
||||
wire.onerror = function(error){
|
||||
reconnect(peer); // placement?
|
||||
if(!error){ return }
|
||||
if(error.code === 'ECONNREFUSED'){
|
||||
//reconnect(peer, as);
|
||||
}
|
||||
reconnect(peer);
|
||||
};
|
||||
wire.onopen = function(){
|
||||
opt.mesh.hi(peer);
|
||||
|
@ -70,7 +70,7 @@ function soul(gun, cb, opt, as){
|
||||
var cat = gun._, acks = 0, tmp;
|
||||
if(tmp = cat.soul || cat.link || cat.dub){ return cb(tmp, as, cat), gun }
|
||||
gun.get(function(msg, ev){
|
||||
if(u === msg.put && (tmp = (obj_map(cat.root.opt.peers, function(v,k,t){t(k)})||[]).length) && ++acks < tmp){
|
||||
if(u === msg.put && (tmp = Object.keys(cat.root.opt.peers).length) && ++acks < tmp){
|
||||
return;
|
||||
}
|
||||
ev.rid(msg);
|
||||
|
@ -84,8 +84,10 @@ function val(msg, eve, to){
|
||||
}
|
||||
}
|
||||
if((tmp = eve.wait) && (tmp = tmp[at.id])){ clearTimeout(tmp) }
|
||||
eve.ack = (eve.ack||0)+1;
|
||||
if(!to && u === data && eve.ack <= (opt.acks || Object.keys(at.root.opt.peers).length)){ return }
|
||||
if((!to && (u === data || at.soul || at.link || (link && !(0 < link.ack))))
|
||||
|| (u === data && (tmp = (obj_map(at.root.opt.peers, function(v,k,t){t(k)})||[]).length) && (!to && (link||at).ack <= tmp))){
|
||||
|| (u === data && (tmp = Object.keys(at.root.opt.peers).length) && (!to && (link||at).ack < tmp))){
|
||||
tmp = (eve.wait = {})[at.id] = setTimeout(function(){
|
||||
val.call({as:opt}, msg, eve, tmp || 1);
|
||||
}, opt.wait || 99);
|
||||
|
@ -191,7 +191,10 @@ Gun.dup = require('./dup');
|
||||
at.opt.peers = obj_to(tmp, at.opt.peers);
|
||||
}
|
||||
at.opt.peers = at.opt.peers || {};
|
||||
obj_to(opt, at.opt); // copies options on to `at.opt` only if not already taken.
|
||||
obj_map(opt, function each(v,k){
|
||||
if(!obj_has(this, k) || text.is(v) || obj.empty(v)){ this[k] = v ; return }
|
||||
obj_map(v, each, this[k]);
|
||||
}, at.opt);
|
||||
Gun.on('opt', at);
|
||||
at.opt.uuid = at.opt.uuid || function(){ return state_lex() + text_rand(12) }
|
||||
return gun;
|
||||
|
@ -95,8 +95,9 @@ Type.obj.copy = function(o){ // because http://web.archive.org/web/2014032822402
|
||||
} t.r = t.r || [];
|
||||
t.r.push(k);
|
||||
};
|
||||
var keys = Object.keys;
|
||||
Type.obj.map = function(l, c, _){
|
||||
var keys = Object.keys, map;
|
||||
Object.keys = Object.keys || function(o){ return map(o, function(v,k,t){t(k)}) }
|
||||
Type.obj.map = map = function(l, c, _){
|
||||
var u, i = 0, x, r, ll, lle, f = fn_is(c);
|
||||
t.r = null;
|
||||
if(keys && obj_is(l)){
|
||||
|
Loading…
x
Reference in New Issue
Block a user