diff --git a/examples/package.json b/examples/package.json index 86eec3c2..0ca3be4a 100644 --- a/examples/package.json +++ b/examples/package.json @@ -8,7 +8,7 @@ } , "dependencies": { "express": "~>4.9.0", - "gun": "0.0.9-k" + "gun": "0.0.9-l" } , "scripts": { "start": "node express.js", diff --git a/gun.js b/gun.js index a055240d..7cab294b 100644 --- a/gun.js +++ b/gun.js @@ -913,28 +913,25 @@ opt.url.pathname = '/' + key; } Gun.log("gun load", key); - (function(){ + (function local(key, cb){ var node, lkey = key[Gun._.soul]? tab.prefix + tab.prenode + key[Gun._.soul] : tab.prefix + tab.prekey + key - if((node = store.get(lkey)) && node[Gun._.soul]){ return tab.load(node, cb) } - setTimeout(function(){cb(null, node)},0); - }()); + if((node = store.get(lkey)) && node[Gun._.soul]){ return local(node, cb) } + if(node){ setTimeout(function(){cb(null, node)},0) } + }(key, cb)); Gun.obj.map(gun.__.opt.peers, function(peer, url){ request(url, null, function(err, reply){ Gun.log('via', url, key, reply.body); if(err || !reply){ return } // handle reconnect? if(reply.body && reply.body.err){ cb(reply.body.err); - } else - if(Gun.is.node(reply.body) || Gun.is.graph(reply.body)){ + } else { if(!key[Gun._.soul] && Gun.is.soul(reply.body)){ var meta = {}; meta[Gun._.soul] = Gun.is.soul(reply.body); - store.set(tab.prefix + tab.prekey + key, meta) + store.set(tab.prefix + tab.prekey + key, meta); } cb(null, reply.body); - } else { - Gun.log(reply.body); } }, opt); cb.peers = true; diff --git a/package.json b/package.json index 30e10b4d..be2f4a28 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "name": "gun" -, "version": "0.0.9-k" +, "version": "0.0.9-l" , "author": "Mark Nadal" , "description": "Graph engine." , "engines": {