mirror of
https://github.com/amark/gun.git
synced 2025-11-24 14:35:55 +00:00
fix gun <-> axe mismatch on uninit data
This commit is contained in:
parent
680f871aa3
commit
f25747443e
8
gun.js
8
gun.js
@ -470,7 +470,9 @@
|
|||||||
//console.log("GET:", get, node, has);
|
//console.log("GET:", get, node, has);
|
||||||
if(!node){ return root.on('get', msg) }
|
if(!node){ return root.on('get', msg) }
|
||||||
if(has){
|
if(has){
|
||||||
if('string' != typeof has || u === node[has]){ return root.on('get', msg) }
|
if('string' != typeof has || u === node[has]){
|
||||||
|
if(!((at||'').next||'')[has]){ root.on('get', msg); return }
|
||||||
|
}
|
||||||
node = state_ify({}, has, state_is(node, has), node[has], soul);
|
node = state_ify({}, has, state_is(node, has), node[has], soul);
|
||||||
// If we have a key in-memory, do we really need to fetch?
|
// If we have a key in-memory, do we really need to fetch?
|
||||||
// Maybe... in case the in-memory key we have is a local write
|
// Maybe... in case the in-memory key we have is a local write
|
||||||
@ -497,7 +499,7 @@
|
|||||||
tmp = keys.length;
|
tmp = keys.length;
|
||||||
console.STAT && console.STAT(S, -(S - (S = +new Date)), 'got copied some');
|
console.STAT && console.STAT(S, -(S - (S = +new Date)), 'got copied some');
|
||||||
DBG && (DBG.ga = +new Date);
|
DBG && (DBG.ga = +new Date);
|
||||||
root.on('in', {'@': to, '#': id, put: put, '%': (tmp? (id = text_rand(9)) : u), $: root.$, _: faith, DBG: DBG});
|
root.on('in', {'@': to, '#': id, put: put, '%': (tmp? (id = text_rand(9)) : u), $: root.$, _: faith, DBG: DBG, FOO: 1});
|
||||||
console.STAT && console.STAT(S, +new Date - S, 'got in');
|
console.STAT && console.STAT(S, +new Date - S, 'got in');
|
||||||
if(!tmp){ return }
|
if(!tmp){ return }
|
||||||
setTimeout.turn(go);
|
setTimeout.turn(go);
|
||||||
@ -620,6 +622,7 @@
|
|||||||
if(at.lex){ Object.keys(at.lex).forEach(function(k){ tmp[k] = at.lex[k] }, tmp = msg.get = msg.get || {}) }
|
if(at.lex){ Object.keys(at.lex).forEach(function(k){ tmp[k] = at.lex[k] }, tmp = msg.get = msg.get || {}) }
|
||||||
if(get['#'] || at.soul){
|
if(get['#'] || at.soul){
|
||||||
get['#'] = get['#'] || at.soul;
|
get['#'] = get['#'] || at.soul;
|
||||||
|
root.graph[get['#']] = root.graph[get['#']] || {_:{'#':get['#'],'>':{}}};
|
||||||
msg['#'] || (msg['#'] = text_rand(9)); // A3120 ?
|
msg['#'] || (msg['#'] = text_rand(9)); // A3120 ?
|
||||||
back = (root.$.get(get['#'])._);
|
back = (root.$.get(get['#'])._);
|
||||||
if(!(get = get['.'])){ // soul
|
if(!(get = get['.'])){ // soul
|
||||||
@ -953,6 +956,7 @@
|
|||||||
next[at.get = key] = at;
|
next[at.get = key] = at;
|
||||||
if(back === cat.root.$){
|
if(back === cat.root.$){
|
||||||
at.soul = key;
|
at.soul = key;
|
||||||
|
//at.put = {};
|
||||||
} else
|
} else
|
||||||
if(cat.soul || cat.has){
|
if(cat.soul || cat.has){
|
||||||
at.has = key;
|
at.has = key;
|
||||||
|
|||||||
17
lib/axe.js
17
lib/axe.js
@ -71,9 +71,26 @@ function start(root){
|
|||||||
if(tmp.it && tmp.it.get && msg.put){ // WHEN SEEING A PUT REPLY TO A GET...
|
if(tmp.it && tmp.it.get && msg.put){ // WHEN SEEING A PUT REPLY TO A GET...
|
||||||
var get = tmp.it.get||'', ref = REF(tmp.it)._, via = (tmp.it._||'').via||'', sub;
|
var get = tmp.it.get||'', ref = REF(tmp.it)._, via = (tmp.it._||'').via||'', sub;
|
||||||
if(via && ref){ // SUBSCRIBE THE PEER WHO ASKED VIA FOR IT:
|
if(via && ref){ // SUBSCRIBE THE PEER WHO ASKED VIA FOR IT:
|
||||||
|
//console.log("SUBSCRIBING", Object.maps(ref.route||''), "to", LEX(get['#']));
|
||||||
via.id && (ref.route || (ref.route = new Object.Map)).set(via.id, via);
|
via.id && (ref.route || (ref.route = new Object.Map)).set(via.id, via);
|
||||||
sub = (via.sub || (via.sub = new Object.Map));
|
sub = (via.sub || (via.sub = new Object.Map));
|
||||||
ref && (sub.get(LEX(get['#'])) || (sub.set(LEX(get['#']), sub = new Object.Map) && sub)).set(LEX(get['.']), 1); // {soul: {'':1, has: 1}}
|
ref && (sub.get(LEX(get['#'])) || (sub.set(LEX(get['#']), sub = new Object.Map) && sub)).set(LEX(get['.']), 1); // {soul: {'':1, has: 1}}
|
||||||
|
|
||||||
|
via = (msg._||'').via||'';
|
||||||
|
if(via){ // BIDIRECTIONAL SUBSCRIBE: REPLIER IS NOW SUBSCRIBED. DO WE WANT THIS?
|
||||||
|
via.id && (ref.route || (ref.route = new Object.Map)).set(via.id, via);
|
||||||
|
sub = (via.sub || (via.sub = new Object.Map));
|
||||||
|
if(ref){
|
||||||
|
var soul = LEX(get['#']), sift = sub.get(soul), has = LEX(get['.']);
|
||||||
|
if(has){
|
||||||
|
(sift || (sub.set(soul, sift = new Object.Map) && sift)).set(has, 1);
|
||||||
|
} else
|
||||||
|
if(!sift){
|
||||||
|
sub.set(soul, sift = new Object.Map);
|
||||||
|
sift.set('', 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((tmp = tmp.back)){ // backtrack OKs since AXE splits PUTs up.
|
if((tmp = tmp.back)){ // backtrack OKs since AXE splits PUTs up.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user