shogun-core 1.10.6 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -65720,108 +65720,6 @@ module.exports = webpackEmptyContext;
|
|
|
65720
65720
|
|
|
65721
65721
|
/***/ }),
|
|
65722
65722
|
|
|
65723
|
-
/***/ "./node_modules/gun/axe.js":
|
|
65724
|
-
/*!*********************************!*\
|
|
65725
|
-
!*** ./node_modules/gun/axe.js ***!
|
|
65726
|
-
\*********************************/
|
|
65727
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
65728
|
-
|
|
65729
|
-
;(function(){
|
|
65730
|
-
|
|
65731
|
-
var sT = setTimeout || {}, u;
|
|
65732
|
-
if("object" !== ''+u){ sT.window = window }
|
|
65733
|
-
var AXE = (sT.window||'').AXE || function(){};
|
|
65734
|
-
if(AXE.window = sT.window){ AXE.window.AXE = AXE }
|
|
65735
|
-
|
|
65736
|
-
var Gun = (AXE.window||'').GUN || __webpack_require__(/*! ./gun */ "./node_modules/gun/gun.js");
|
|
65737
|
-
(Gun.AXE = AXE).GUN = AXE.Gun = Gun;
|
|
65738
|
-
|
|
65739
|
-
//if(!Gun.window){ try{ require('./lib/axe') }catch(e){} }
|
|
65740
|
-
if(!Gun.window){ __webpack_require__(/*! ./lib/axe */ "./node_modules/gun/lib/axe.js") }
|
|
65741
|
-
|
|
65742
|
-
Gun.on('opt', function(at){ start(at) ; this.to.next(at) }); // make sure to call the "next" middleware adapter.
|
|
65743
|
-
|
|
65744
|
-
function start(root){
|
|
65745
|
-
if(root.axe){ return }
|
|
65746
|
-
var opt = root.opt, peers = opt.peers;
|
|
65747
|
-
if(false === opt.axe){ return }
|
|
65748
|
-
if(!Gun.window){ return } // handled by ^ lib/axe.js
|
|
65749
|
-
var w = Gun.window, lS = w.localStorage || opt.localStorage || {}, loc = w.location || opt.location || {}, nav = w.navigator || opt.navigator || {};
|
|
65750
|
-
var axe = root.axe = {}, tmp, id;
|
|
65751
|
-
var mesh = opt.mesh = opt.mesh || Gun.Mesh(root); // DAM!
|
|
65752
|
-
|
|
65753
|
-
tmp = peers[id = loc.origin + '/gun'] = peers[id] || {};
|
|
65754
|
-
tmp.id = tmp.url = id; tmp.retry = tmp.retry || 0;
|
|
65755
|
-
tmp = peers[id = 'http://localhost:8765/gun'] = peers[id] || {};
|
|
65756
|
-
tmp.id = tmp.url = id; tmp.retry = tmp.retry || 0;
|
|
65757
|
-
Gun.log.once("AXE", "AXE enabled: Trying to find network via (1) local peer (2) last used peers (3) a URL parameter, and last (4) hard coded peers.");
|
|
65758
|
-
Gun.log.once("AXEWarn", "Warning: AXE is in alpha, use only for testing!");
|
|
65759
|
-
var last = lS.peers || ''; if(last){ last += ' ' }
|
|
65760
|
-
last += ((loc.search||'').split('peers=')[1]||'').split('&')[0];
|
|
65761
|
-
|
|
65762
|
-
root.on('bye', function(peer){
|
|
65763
|
-
this.to.next(peer);
|
|
65764
|
-
if(!peer.url){ return } // ignore WebRTC disconnects for now.
|
|
65765
|
-
if(!nav.onLine){ peer.retry = 1 }
|
|
65766
|
-
if(peer.retry){ return }
|
|
65767
|
-
if(axe.fall){ delete axe.fall[peer.url || peer.id] }
|
|
65768
|
-
(function next(){
|
|
65769
|
-
if(!axe.fall){ setTimeout(next, 9); return } // not found yet
|
|
65770
|
-
var fall = Object.keys(axe.fall||''), one = fall[(Math.random()*fall.length) >> 0];
|
|
65771
|
-
if(!fall.length){ lS.peers = ''; one = 'https://gunjs.herokuapp.com/gun' } // out of peers
|
|
65772
|
-
if(peers[one]){ next(); return } // already choose
|
|
65773
|
-
mesh.hi(one);
|
|
65774
|
-
}());
|
|
65775
|
-
});
|
|
65776
|
-
|
|
65777
|
-
root.on('hi', function(peer){ // TEMPORARY! Try to connect all peers.
|
|
65778
|
-
this.to.next(peer);
|
|
65779
|
-
if(!peer.url){ return } // ignore WebRTC disconnects for now.
|
|
65780
|
-
return; // DO NOT COMMIT THIS FEATURE YET! KEEP TESTING NETWORK PERFORMANCE FIRST!
|
|
65781
|
-
// removed by dead control flow
|
|
65782
|
-
|
|
65783
|
-
});
|
|
65784
|
-
|
|
65785
|
-
function found(text){
|
|
65786
|
-
|
|
65787
|
-
axe.fall = {};
|
|
65788
|
-
((text||'').match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/ig)||[]).forEach(function(url){
|
|
65789
|
-
axe.fall[url] = {url: url, id: url, retry: 0}; // RETRY
|
|
65790
|
-
});
|
|
65791
|
-
|
|
65792
|
-
return;
|
|
65793
|
-
|
|
65794
|
-
// TODO: Finish porting below? Maybe not.
|
|
65795
|
-
|
|
65796
|
-
// removed by dead control flow
|
|
65797
|
-
|
|
65798
|
-
// removed by dead control flow
|
|
65799
|
-
|
|
65800
|
-
// removed by dead control flow
|
|
65801
|
-
|
|
65802
|
-
|
|
65803
|
-
// removed by dead control flow
|
|
65804
|
-
var mesh; // DAM!
|
|
65805
|
-
// removed by dead control flow
|
|
65806
|
-
|
|
65807
|
-
}
|
|
65808
|
-
|
|
65809
|
-
if(last){ found(last); return }
|
|
65810
|
-
try{ fetch(((loc.search||'').split('axe=')[1]||'').split('&')[0] || loc.axe || 'https://raw.githubusercontent.com/wiki/amark/gun/volunteer.dht.md').then(function(res){
|
|
65811
|
-
return res.text()
|
|
65812
|
-
}).then(function(text){
|
|
65813
|
-
found(lS.peers = text);
|
|
65814
|
-
}).catch(function(){
|
|
65815
|
-
found(); // nothing
|
|
65816
|
-
})}catch(e){found()}
|
|
65817
|
-
}
|
|
65818
|
-
|
|
65819
|
-
var empty = {}, yes = true;
|
|
65820
|
-
try{ if("object" != ''+u){ module.exports = AXE } }catch(e){}
|
|
65821
|
-
}());
|
|
65822
|
-
|
|
65823
|
-
/***/ }),
|
|
65824
|
-
|
|
65825
65723
|
/***/ "./node_modules/gun/gun.js":
|
|
65826
65724
|
/*!*********************************!*\
|
|
65827
65725
|
!*** ./node_modules/gun/gun.js ***!
|
|
@@ -68139,269 +68037,6 @@ module.exports = webpackEmptyContext;
|
|
|
68139
68037
|
Type.graph = Type.graph || Graph;
|
|
68140
68038
|
}());
|
|
68141
68039
|
|
|
68142
|
-
/***/ }),
|
|
68143
|
-
|
|
68144
|
-
/***/ "./node_modules/gun/lib/axe.js":
|
|
68145
|
-
/*!*************************************!*\
|
|
68146
|
-
!*** ./node_modules/gun/lib/axe.js ***!
|
|
68147
|
-
\*************************************/
|
|
68148
|
-
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
|
68149
|
-
|
|
68150
|
-
/* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");
|
|
68151
|
-
// I don't quite know where this should go yet, so putting it here
|
|
68152
|
-
// what will probably wind up happening is that minimal AXE logic added to end of gun.js
|
|
68153
|
-
// and then rest of AXE logic (here) will be moved back to gun/axe.js
|
|
68154
|
-
// but for now... I gotta rush this out!
|
|
68155
|
-
var Gun = ( true)? window.Gun : 0, u;
|
|
68156
|
-
Gun.on('opt', function(at){ start(at); this.to.next(at) }); // make sure to call the "next" middleware adapter.
|
|
68157
|
-
// TODO: BUG: panic test/panic/1 & test/panic/3 fail when AXE is on.
|
|
68158
|
-
function start(root){
|
|
68159
|
-
if(root.axe){ return }
|
|
68160
|
-
var opt = root.opt, peers = opt.peers;
|
|
68161
|
-
if(false === opt.axe){ return }
|
|
68162
|
-
if((typeof process !== "undefined") && 'false' === ''+(process.env||'').AXE){ return }
|
|
68163
|
-
Gun.log.once("AXE", "AXE relay enabled!");
|
|
68164
|
-
var axe = root.axe = {}, tmp, id;
|
|
68165
|
-
var mesh = opt.mesh = opt.mesh || Gun.Mesh(root); // DAM!
|
|
68166
|
-
var dup = root.dup;
|
|
68167
|
-
|
|
68168
|
-
mesh.way = function(msg){
|
|
68169
|
-
if(!msg){ return }
|
|
68170
|
-
//relayUp(msg); // TEMPORARY!!!
|
|
68171
|
-
if(msg.get){ return GET(msg) }
|
|
68172
|
-
if(msg.put){ return }
|
|
68173
|
-
fall(msg);
|
|
68174
|
-
}
|
|
68175
|
-
|
|
68176
|
-
function GET(msg){
|
|
68177
|
-
if(!msg){ return }
|
|
68178
|
-
var via = (msg._||'').via, soul, has, tmp, ref;
|
|
68179
|
-
if(!via || !via.id){ return fall(msg) }
|
|
68180
|
-
// SUBSCRIPTION LOGIC MOVED TO GET'S ACK REPLY.
|
|
68181
|
-
if(!(ref = REF(msg)._)){ return fall(msg) }
|
|
68182
|
-
ref.asked = +new Date;
|
|
68183
|
-
GET.turn(msg, ref.route, 0);
|
|
68184
|
-
}
|
|
68185
|
-
GET.turn = function(msg, route, turn){
|
|
68186
|
-
var tmp = msg['#'], tag = dup.s[tmp], next;
|
|
68187
|
-
if(!tmp || !tag){ return } // message timed out, GUN may require us to relay, tho AXE does not like that. Rethink?
|
|
68188
|
-
// TOOD: BUG! Handle edge case where live updates occur while these turn hashes are being checked (they'll never be consistent), but we don't want to degrade to O(N), if we know the via asking peer got an update, then we should do something like cancel these turns asking for data.
|
|
68189
|
-
// Ideas: Save a random seed that sorts the route, store it and the index. // Or indexing on lowest latency is probably better.
|
|
68190
|
-
clearTimeout(tag.lack);
|
|
68191
|
-
if(tag.ack && (tmp = tag['##']) && msg['##'] === tmp){ return } // hashes match, stop asking other peers!
|
|
68192
|
-
next = (Object.maps(route||opt.peers)).slice(turn = turn || 0);
|
|
68193
|
-
if(!next.length){
|
|
68194
|
-
if(!route){ return } // asked all peers, stop asking!
|
|
68195
|
-
GET.turn(msg, u, 0); // asked all subs, now now ask any peers. (not always the best idea, but stays )
|
|
68196
|
-
return;
|
|
68197
|
-
}
|
|
68198
|
-
setTimeout.each(next, function(id){
|
|
68199
|
-
var peer = opt.peers[id]; turn++;
|
|
68200
|
-
if(!peer || !peer.wire){ route && route.delete(id); return } // bye! // TODO: CHECK IF 0 OTHER PEERS & UNSUBSCRIBE
|
|
68201
|
-
if(mesh.say(msg, peer) === false){ return } // was self
|
|
68202
|
-
if(0 == (turn % 3)){ return 1 }
|
|
68203
|
-
}, function(){
|
|
68204
|
-
tag['##'] = msg['##']; // should probably set this in a more clever manner, do live `in` checks ++ --, etc. but being lazy for now. // TODO: Yes, see `in` TODO, currently this might match against only in-mem cause no other peers reply, which is "fine", but could cause a false positive.
|
|
68205
|
-
tag.lack = setTimeout(function(){ GET.turn(msg, route, turn) }, 25);
|
|
68206
|
-
}, 3);
|
|
68207
|
-
}
|
|
68208
|
-
function fall(msg){ mesh.say(msg, opt.peers) }
|
|
68209
|
-
function REF(msg){
|
|
68210
|
-
var ref = '', soul, has, tmp;
|
|
68211
|
-
if(!msg || !msg.get){ return ref }
|
|
68212
|
-
if('string' == typeof (soul = msg.get['#'])){ ref = root.$.get(soul) }
|
|
68213
|
-
if('string' == typeof (tmp = msg.get['.'])){ has = tmp } else { has = '' }
|
|
68214
|
-
|
|
68215
|
-
var via = (msg._||'').via, sub = (via.sub || (via.sub = new Object.Map)); (sub.get(soul) || (sub.set(soul, tmp = new Object.Map) && tmp)).set(has, 1); // {soul: {'':1, has: 1}} // TEMPORARILY REVERT AXE TOWER TYING TO SUBSCRIBING TO EVERYTHING. UNDO THIS!
|
|
68216
|
-
via.id && ref._ && (ref._.route || (ref._.route = new Object.Map)).set(via.id, via); // SAME AS ^
|
|
68217
|
-
|
|
68218
|
-
return ref;
|
|
68219
|
-
}
|
|
68220
|
-
function LEX(lex){ return (lex = lex || '')['='] || lex['*'] || lex['>'] || lex }
|
|
68221
|
-
|
|
68222
|
-
root.on('in', function(msg){ var to = this.to, tmp;
|
|
68223
|
-
if((tmp = msg['@']) && (tmp = dup.s[tmp])){
|
|
68224
|
-
tmp.ack = (tmp.ack || 0) + 1; // count remote ACKs to GET. // TODO: If mismatch, should trigger next asks.
|
|
68225
|
-
if(tmp.it && tmp.it.get && msg.put){ // WHEN SEEING A PUT REPLY TO A GET...
|
|
68226
|
-
var get = tmp.it.get||'', ref = REF(tmp.it)._, via = (tmp.it._||'').via||'', sub;
|
|
68227
|
-
if(via && ref){ // SUBSCRIBE THE PEER WHO ASKED VIA FOR IT:
|
|
68228
|
-
//console.log("SUBSCRIBING", Object.maps(ref.route||''), "to", LEX(get['#']));
|
|
68229
|
-
via.id && (ref.route || (ref.route = new Object.Map)).set(via.id, via);
|
|
68230
|
-
sub = (via.sub || (via.sub = new Object.Map));
|
|
68231
|
-
ref && (sub.get(LEX(get['#'])) || (sub.set(LEX(get['#']), sub = new Object.Map) && sub)).set(LEX(get['.']), 1); // {soul: {'':1, has: 1}}
|
|
68232
|
-
|
|
68233
|
-
via = (msg._||'').via||'';
|
|
68234
|
-
if(via){ // BIDIRECTIONAL SUBSCRIBE: REPLIER IS NOW SUBSCRIBED. DO WE WANT THIS?
|
|
68235
|
-
via.id && (ref.route || (ref.route = new Object.Map)).set(via.id, via);
|
|
68236
|
-
sub = (via.sub || (via.sub = new Object.Map));
|
|
68237
|
-
if(ref){
|
|
68238
|
-
var soul = LEX(get['#']), sift = sub.get(soul), has = LEX(get['.']);
|
|
68239
|
-
if(has){
|
|
68240
|
-
(sift || (sub.set(soul, sift = new Object.Map) && sift)).set(has, 1);
|
|
68241
|
-
} else
|
|
68242
|
-
if(!sift){
|
|
68243
|
-
sub.set(soul, sift = new Object.Map);
|
|
68244
|
-
sift.set('', 1);
|
|
68245
|
-
}
|
|
68246
|
-
}
|
|
68247
|
-
}
|
|
68248
|
-
}
|
|
68249
|
-
}
|
|
68250
|
-
if((tmp = tmp.back)){ // backtrack OKs since AXE splits PUTs up.
|
|
68251
|
-
setTimeout.each(Object.keys(tmp), function(id){
|
|
68252
|
-
to.next({'#': msg['#'], '@': id, ok: msg.ok});
|
|
68253
|
-
});
|
|
68254
|
-
return;
|
|
68255
|
-
}
|
|
68256
|
-
}
|
|
68257
|
-
to.next(msg);
|
|
68258
|
-
});
|
|
68259
|
-
|
|
68260
|
-
root.on('create', function(root){
|
|
68261
|
-
this.to.next(root);
|
|
68262
|
-
var Q = {};
|
|
68263
|
-
root.on('put', function(msg){
|
|
68264
|
-
var eve = this, at = eve.as, put = msg.put, soul = put['#'], has = put['.'], val = put[':'], state = put['>'], q, tmp;
|
|
68265
|
-
eve.to.next(msg);
|
|
68266
|
-
if(msg['@']){ return } // acks send existing data, not updates, so no need to resend to others.
|
|
68267
|
-
if(!soul || !has){ return }
|
|
68268
|
-
var ref = root.$.get(soul)._, route = (ref||'').route;
|
|
68269
|
-
if(!route){ return }
|
|
68270
|
-
if(ref.skip && ref.skip.has == has){ ref.skip.now = msg['#']; return }
|
|
68271
|
-
(ref.skip = {now: msg['#'], has: has}).to = setTimeout(function(){
|
|
68272
|
-
setTimeout.each(Object.maps(route), function(pid){ var peer, tmp;
|
|
68273
|
-
var skip = ref.skip||''; ref.skip = null;
|
|
68274
|
-
if(!(peer = route.get(pid))){ return }
|
|
68275
|
-
if(!peer.wire){ route.delete(pid); return } // bye!
|
|
68276
|
-
var sub = (peer.sub || (peer.sub = new Object.Map)).get(soul);
|
|
68277
|
-
if(!sub){ return }
|
|
68278
|
-
if(!sub.get(has) && !sub.get('')){ return }
|
|
68279
|
-
var put = peer.put || (peer.put = {});
|
|
68280
|
-
var node = root.graph[soul], tmp;
|
|
68281
|
-
if(node && u !== (tmp = node[has])){
|
|
68282
|
-
state = state_is(node, has);
|
|
68283
|
-
val = tmp;
|
|
68284
|
-
}
|
|
68285
|
-
put[soul] = state_ify(put[soul], has, state, val, soul);
|
|
68286
|
-
tmp = dup.track(peer.next = peer.next || String.random(9));
|
|
68287
|
-
(tmp.back || (tmp.back = {}))[''+(skip.now||msg['#'])] = 1;
|
|
68288
|
-
if(peer.to){ return }
|
|
68289
|
-
peer.to = setTimeout(function(){ flush(peer) }, opt.gap);
|
|
68290
|
-
}) }, 9);
|
|
68291
|
-
});
|
|
68292
|
-
});
|
|
68293
|
-
|
|
68294
|
-
function flush(peer){
|
|
68295
|
-
var msg = {'#': peer.next, put: peer.put, ok: {'@': 3, '/': mesh.near}}; // BUG: TODO: sub count!
|
|
68296
|
-
// TODO: what about DAM's >< dedup? Current thinking is, don't use it, however, you could store first msg# & latest msg#, and if here... latest === first then likely it is the same >< thing, so if(firstMsg['><'][peer.id]){ return } don't send.
|
|
68297
|
-
peer.next = peer.put = peer.to = null;
|
|
68298
|
-
mesh.say(msg, peer);
|
|
68299
|
-
}
|
|
68300
|
-
var state_ify = Gun.state.ify, state_is = Gun.state.is;
|
|
68301
|
-
|
|
68302
|
-
function relayUp(msg){
|
|
68303
|
-
mesh.say(msg, axe.up);
|
|
68304
|
-
}
|
|
68305
|
-
|
|
68306
|
-
;(function(){ // THIS IS THE UP MODULE;
|
|
68307
|
-
axe.up = {};
|
|
68308
|
-
var hi = mesh.hear['?']; // lower-level integration with DAM! This is abnormal but helps performance.
|
|
68309
|
-
mesh.hear['?'] = function(msg, peer){ var p; // deduplicate unnecessary connections:
|
|
68310
|
-
hi(msg, peer);
|
|
68311
|
-
if(!peer.pid){ return }
|
|
68312
|
-
if(peer.pid === opt.pid){ mesh.bye(peer); return } // if I connected to myself, drop.
|
|
68313
|
-
if(p = axe.up[peer.pid]){ // if we both connected to each other...
|
|
68314
|
-
if(p === peer){ return } // do nothing if no conflict,
|
|
68315
|
-
if(opt.pid > peer.pid){ // else deterministically sort
|
|
68316
|
-
p = peer; // so we will wind up choosing the same to keep
|
|
68317
|
-
peer = axe.up[p.pid]; // and the same to drop.
|
|
68318
|
-
}
|
|
68319
|
-
p.url = p.url || peer.url; // copy if not
|
|
68320
|
-
mesh.bye(peer); // drop
|
|
68321
|
-
axe.up[p.pid] = p; // update same to be same.
|
|
68322
|
-
return;
|
|
68323
|
-
}
|
|
68324
|
-
if(!peer.url){ return }
|
|
68325
|
-
axe.up[peer.pid] = peer;
|
|
68326
|
-
if(axe.stay){ axe.stay() }
|
|
68327
|
-
};
|
|
68328
|
-
|
|
68329
|
-
mesh.hear['opt'] = function(msg, peer){
|
|
68330
|
-
if(msg.ok){ return }
|
|
68331
|
-
var tmp = msg.opt;
|
|
68332
|
-
if(!tmp){ return }
|
|
68333
|
-
tmp = tmp.peers;
|
|
68334
|
-
if(!tmp || 'string' != typeof tmp){ return }
|
|
68335
|
-
if(99 <= Object.keys(axe.up).length){ return } // 99 TEMPORARILY UNTIL BENCHMARKED!
|
|
68336
|
-
mesh.hi({id: tmp, url: tmp, retry: 9});
|
|
68337
|
-
if(peer){ mesh.say({dam: 'opt', ok: 1, '@': msg['#']}, peer) }
|
|
68338
|
-
}
|
|
68339
|
-
|
|
68340
|
-
axe.stay = function(){
|
|
68341
|
-
clearTimeout(axe.stay.to);
|
|
68342
|
-
axe.stay.to = setTimeout(function(tmp, urls){
|
|
68343
|
-
if(!(tmp = root.stats && root.stats.stay)){ return }
|
|
68344
|
-
urls = {}; Object.keys(axe.up||'').forEach(function(p){
|
|
68345
|
-
p = (axe.up||'')[p]; if(p.url){ urls[p.url] = {} }
|
|
68346
|
-
});
|
|
68347
|
-
(tmp.axe = tmp.axe || {}).up = urls;
|
|
68348
|
-
}, 1000 * 9);//1000 * 60);
|
|
68349
|
-
};
|
|
68350
|
-
setTimeout(function(tmp){
|
|
68351
|
-
if(!(tmp = root.stats && root.stats.stay && root.stats.stay.axe)){ return }
|
|
68352
|
-
if(!(tmp = tmp.up)){ return }
|
|
68353
|
-
if(!(tmp instanceof Array)){ tmp = Object.keys(tmp) }
|
|
68354
|
-
setTimeout.each(tmp||[], function(url){ mesh.hear.opt({opt: {peers: url}}) });
|
|
68355
|
-
},1000);
|
|
68356
|
-
}());
|
|
68357
|
-
|
|
68358
|
-
;(function(){ // THIS IS THE MOB MODULE;
|
|
68359
|
-
//return; // WORK IN PROGRESS, TEST FINALIZED, NEED TO MAKE STABLE.
|
|
68360
|
-
/*
|
|
68361
|
-
AXE should have a couple of threshold items...
|
|
68362
|
-
let's pretend there is a variable max peers connected
|
|
68363
|
-
mob = 10000
|
|
68364
|
-
if we get more peers than that...
|
|
68365
|
-
we should start sending those peers a remote command
|
|
68366
|
-
that they should connect to this or that other peer
|
|
68367
|
-
and then once they (or before they do?) drop them from us.
|
|
68368
|
-
sake of the test... gonna set that peer number to 1.
|
|
68369
|
-
The mob threshold might be determined by other factors,
|
|
68370
|
-
like how much RAM or CPU stress we have.
|
|
68371
|
-
*/
|
|
68372
|
-
opt.mob = opt.mob || 9900; // should be based on ulimit, some clouds as low as 10K.
|
|
68373
|
-
|
|
68374
|
-
// handle rebalancing a mob of peers:
|
|
68375
|
-
root.on('hi', function(peer){
|
|
68376
|
-
this.to.next(peer);
|
|
68377
|
-
if(peer.url){ return } // I am assuming that if we are wanting to make an outbound connection to them, that we don't ever want to drop them unless our actual config settings change.
|
|
68378
|
-
var count = /*Object.keys(opt.peers).length ||*/ mesh.near; // TODO: BUG! This is slow, use .near, but near is buggy right now, fix in DAM.
|
|
68379
|
-
//console.log("are we mobbed?", opt.mob, Object.keys(opt.peers).length, mesh.near);
|
|
68380
|
-
if(opt.mob >= count){ return } // TODO: Make dynamic based on RAM/CPU also. Or possibly even weird stuff like opt.mob / axe.up length?
|
|
68381
|
-
var peers = {};Object.keys(axe.up).forEach(function(p){ p = axe.up[p]; p.url && (peers[p.url]={}) });
|
|
68382
|
-
// TODO: BUG!!! Infinite reconnection loop happens if not enough relays, or if some are missing. For instance, :8766 says to connect to :8767 which then says to connect to :8766. To not DDoS when system overload, figure clever way to tell peers to retry later, that network does not have enough capacity?
|
|
68383
|
-
mesh.say({dam: 'mob', mob: count, peers: peers}, peer);
|
|
68384
|
-
setTimeout(function(){ mesh.bye(peer) }, 9); // something with better perf?
|
|
68385
|
-
});
|
|
68386
|
-
root.on('bye', function(peer){
|
|
68387
|
-
this.to.next(peer);
|
|
68388
|
-
});
|
|
68389
|
-
|
|
68390
|
-
}());
|
|
68391
|
-
}
|
|
68392
|
-
|
|
68393
|
-
;(function(){
|
|
68394
|
-
var from = Array.from;
|
|
68395
|
-
Object.maps = function(o){
|
|
68396
|
-
if(from && o instanceof Map){ return from(o.keys()) }
|
|
68397
|
-
if(o instanceof Object.Map){ o = o.s }
|
|
68398
|
-
return Object.keys(o);
|
|
68399
|
-
}
|
|
68400
|
-
if(from){ return Object.Map = Map }
|
|
68401
|
-
(Object.Map = function(){ this.s = {} }).prototype = {set:function(k,v){this.s[k]=v;return this},get:function(k){return this.s[k]},delete:function(k){delete this.s[k]}};
|
|
68402
|
-
}());
|
|
68403
|
-
|
|
68404
|
-
|
|
68405
68040
|
/***/ }),
|
|
68406
68041
|
|
|
68407
68042
|
/***/ "./node_modules/gun/lib/radisk.js":
|
|
@@ -69424,38 +69059,6 @@ Gun.on('create', function(root){
|
|
|
69424
69059
|
var statg = 0, statp = 0; // STATS!
|
|
69425
69060
|
});
|
|
69426
69061
|
|
|
69427
|
-
/***/ }),
|
|
69428
|
-
|
|
69429
|
-
/***/ "./node_modules/gun/lib/then.js":
|
|
69430
|
-
/*!**************************************!*\
|
|
69431
|
-
!*** ./node_modules/gun/lib/then.js ***!
|
|
69432
|
-
\**************************************/
|
|
69433
|
-
/***/ (() => {
|
|
69434
|
-
|
|
69435
|
-
var Gun = ( true)? window.Gun : 0;
|
|
69436
|
-
|
|
69437
|
-
// Returns a gun reference in a promise and then calls a callback if specified
|
|
69438
|
-
Gun.chain.promise = function(cb) {
|
|
69439
|
-
var gun = this, cb = cb || function(ctx) { return ctx };
|
|
69440
|
-
return (new Promise(function(res, rej) {
|
|
69441
|
-
gun.once(function(data, key){
|
|
69442
|
-
res({put: data, get: key, gun: this}); // gun reference is returned by promise
|
|
69443
|
-
});
|
|
69444
|
-
})).then(cb); //calling callback with resolved data
|
|
69445
|
-
};
|
|
69446
|
-
|
|
69447
|
-
// Returns a promise for the data, key of the gun call
|
|
69448
|
-
Gun.chain.then = function(cb) {
|
|
69449
|
-
var gun = this;
|
|
69450
|
-
var p = (new Promise((res, rej)=>{
|
|
69451
|
-
gun.once(function (data, key) {
|
|
69452
|
-
res(data, key); //call resolve when data is returned
|
|
69453
|
-
})
|
|
69454
|
-
}))
|
|
69455
|
-
return cb ? p.then(cb) : p;
|
|
69456
|
-
};
|
|
69457
|
-
|
|
69458
|
-
|
|
69459
69062
|
/***/ }),
|
|
69460
69063
|
|
|
69461
69064
|
/***/ "./node_modules/gun/lib/webrtc.js":
|
|
@@ -103515,21 +103118,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
103515
103118
|
};
|
|
103516
103119
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
103517
103120
|
exports.createGun = exports.restrictedPut = exports.derive = exports.GunErrors = exports.crypto = exports.GunRxJS = exports.SEA = exports.GunInstance = exports.Gun = void 0;
|
|
103518
|
-
// Import Gun - will be bundled internally
|
|
103519
103121
|
const gun_1 = __importDefault(__webpack_require__(/*! gun/gun */ "./node_modules/gun/gun.js"));
|
|
103520
103122
|
const Gun = gun_1.default;
|
|
103521
103123
|
exports.Gun = Gun;
|
|
103522
103124
|
const sea_1 = __importDefault(__webpack_require__(/*! gun/sea */ "./node_modules/gun/sea.js"));
|
|
103523
103125
|
exports.SEA = sea_1.default;
|
|
103524
|
-
__webpack_require__(/*! gun/lib/then.js */ "./node_modules/gun/lib/then.js");
|
|
103525
103126
|
__webpack_require__(/*! gun/lib/radix.js */ "./node_modules/gun/lib/radix.js");
|
|
103526
103127
|
__webpack_require__(/*! gun/lib/radisk.js */ "./node_modules/gun/lib/radisk.js");
|
|
103527
|
-
__webpack_require__(/*! gun/lib/store.js */ "./node_modules/gun/lib/store.js");
|
|
103528
103128
|
__webpack_require__(/*! gun/lib/rindexed.js */ "./node_modules/gun/lib/rindexed.js");
|
|
103129
|
+
__webpack_require__(/*! gun/lib/store.js */ "./node_modules/gun/lib/store.js");
|
|
103130
|
+
__webpack_require__(/*! gun/lib/wire.js */ "./node_modules/gun/lib/wire.js");
|
|
103529
103131
|
__webpack_require__(/*! gun/lib/webrtc.js */ "./node_modules/gun/lib/webrtc.js");
|
|
103530
103132
|
__webpack_require__(/*! gun/lib/yson.js */ "./node_modules/gun/lib/yson.js");
|
|
103531
|
-
__webpack_require__(/*! gun/lib/wire.js */ "./node_modules/gun/lib/wire.js");
|
|
103532
|
-
__webpack_require__(/*! gun/axe.js */ "./node_modules/gun/axe.js");
|
|
103533
103133
|
const restricted_put_1 = __webpack_require__(/*! ./restricted-put */ "./src/gundb/restricted-put.ts");
|
|
103534
103134
|
Object.defineProperty(exports, "restrictedPut", ({ enumerable: true, get: function () { return restricted_put_1.restrictedPut; } }));
|
|
103535
103135
|
const derive_1 = __importDefault(__webpack_require__(/*! ./derive */ "./src/gundb/derive.ts"));
|
|
@@ -103603,9 +103203,11 @@ class GunInstance {
|
|
|
103603
103203
|
this.node = this.gun.get(appScope);
|
|
103604
103204
|
if (sessionResult.success) {
|
|
103605
103205
|
// Session automatically restored
|
|
103206
|
+
console.log("Session automatically restored");
|
|
103606
103207
|
}
|
|
103607
103208
|
else {
|
|
103608
103209
|
// No previous session to restore
|
|
103210
|
+
console.log("No previous session to restore");
|
|
103609
103211
|
}
|
|
103610
103212
|
}
|
|
103611
103213
|
catch (error) {
|
|
@@ -105717,7 +105319,6 @@ async function loadGunModules() {
|
|
|
105717
105319
|
"gun/lib/radix",
|
|
105718
105320
|
"gun/lib/radisk",
|
|
105719
105321
|
"gun/lib/webrtc",
|
|
105720
|
-
"gun/axe",
|
|
105721
105322
|
];
|
|
105722
105323
|
for (const lib of nodeOnlyLibs) {
|
|
105723
105324
|
try {
|