diff --git a/axe.js b/axe.js
index bb7a2008..7f06c34e 100644
--- a/axe.js
+++ b/axe.js
@@ -60,6 +60,20 @@
// with one common superpeer (with ready failovers)
// in case the p2p linear latency is high.
// Or there could be plenty of other better options.
+
+ /*
+ AXE should have a couple of threshold items...
+ let's pretend there is a variable max peers connected
+ mob = 10000
+ if we get more peers than that...
+ we should start sending those peers a remote command
+ that they should connect to this or that other peer
+ and then once they (or before they do?) drop them from us.
+ sake of the test... gonna set that peer number to 1.
+ The mob threshold might be determined by other factors,
+ like how much RAM or CPU stress we have.
+ */
+ opt.mob = opt.mob || Infinity;
var mesh = opt.mesh = opt.mesh || Gun.Mesh(at);
console.log("AXE enabled.");
@@ -256,7 +270,7 @@
this.to.next(peer);
if(!peer.url){ return }
axe.up[peer.id] = peer;
- })
+ });
at.on('bye', function(peer){ this.to.next(peer);
if(peer.url){ delete axe.up[peer.id] }
Gun.obj.map(peer.routes, function(route, hash){
@@ -266,6 +280,19 @@
}
});
});
+
+ // handle rebalancing a mob of peers:
+ at.on('hi', function(peer){
+ this.to.next(peer);
+ 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.
+ var count = Object.keys(opt.peers).length;
+ if(opt.mob >= count){ return } // TODO: Make dynamic based on RAM/CPU also. Or possibly even weird stuff like opt.mob / axe.up length?
+ mesh.say({dam: 'mob', mob: count, peers: Object.keys(axe.up)}, peer);
+ //setTimeout(function(){ mesh.bye(peer) }, 9); // something with better perf? // UNCOMMENT WHEN WE ACTIVATE THIS FEATURE
+ });
+ at.on('bye', function(peer){
+ this.to.next(peer);
+ });
}
function joindht(dht, soul, pids) {
diff --git a/examples/docs.html b/examples/docs.html
index 1adf9b2b..f0d734e2 100644
--- a/examples/docs.html
+++ b/examples/docs.html
@@ -31,12 +31,18 @@
+
+
+
+
+