mirror of
https://github.com/amark/gun.git
synced 2025-06-07 06:36:46 +00:00
fix chain emit & faith
This commit is contained in:
parent
da7c243fb0
commit
9de7d0f38d
7
gun.js
7
gun.js
@ -799,12 +799,13 @@
|
|||||||
var stop = {};
|
var stop = {};
|
||||||
var root = ctx.root, next = root.next||'', put = ctx.put, tmp;
|
var root = ctx.root, next = root.next||'', put = ctx.put, tmp;
|
||||||
var S = +new Date;
|
var S = +new Date;
|
||||||
Gun.graph.is(put, function(node, soul){
|
//Gun.graph.is(put, function(node, soul){
|
||||||
if(!(tmp = next[soul]) || !tmp.$){ return }
|
for(var soul in put){ var node = put[soul]; // Gun.obj.native() makes this safe.
|
||||||
|
if(!(tmp = next[soul]) || !tmp.$){ continue }
|
||||||
root.stop = stop; // temporary fix till a better solution?
|
root.stop = stop; // temporary fix till a better solution?
|
||||||
tmp.on('in', {$: tmp.$, get: soul, put: node});
|
tmp.on('in', {$: tmp.$, get: soul, put: node});
|
||||||
root.stop = null; // temporary fix till a better solution?
|
root.stop = null; // temporary fix till a better solution?
|
||||||
});
|
}
|
||||||
console.STAT && console.STAT(S, +new Date - S, 'fire');
|
console.STAT && console.STAT(S, +new Date - S, 'fire');
|
||||||
ctx.DBG && (ctx.DBG.f = +new Date);
|
ctx.DBG && (ctx.DBG.f = +new Date);
|
||||||
if(!(tmp = ctx.out)){ return }
|
if(!(tmp = ctx.out)){ return }
|
||||||
|
@ -101,7 +101,7 @@
|
|||||||
DBG && (DBG.sa = DBG.sa || +new Date);
|
DBG && (DBG.sa = DBG.sa || +new Date);
|
||||||
DBG && (DBG.sal = q.length);
|
DBG && (DBG.sal = q.length);
|
||||||
var ack, tmp;
|
var ack, tmp;
|
||||||
// TODO!!!! CHANGE THIS INTO PUFF!!!!
|
// TODO!!!! CHANGE THIS INTO PUFF!!!!!!!!!!!!!!!!
|
||||||
for(var id in r.tags){
|
for(var id in r.tags){
|
||||||
if(!r.tags.hasOwnProperty(id)){ continue } var tag = r.tags[id];
|
if(!r.tags.hasOwnProperty(id)){ continue } var tag = r.tags[id];
|
||||||
if((tmp = r.disk[f]) && (tmp = tmp.tags) && tmp[tag]){ continue }
|
if((tmp = r.disk[f]) && (tmp = tmp.tags) && tmp[tag]){ continue }
|
||||||
@ -366,7 +366,7 @@
|
|||||||
p.disk.$ = json;
|
p.disk.$ = json;
|
||||||
console.STAT && (ST = +new Date - S) > 9 && console.STAT(S, ST, 'rad parsed JSON');
|
console.STAT && (ST = +new Date - S) > 9 && console.STAT(S, ST, 'rad parsed JSON');
|
||||||
DBG && (DBG.rpd = +new Date);
|
DBG && (DBG.rpd = +new Date);
|
||||||
p.map(q, p.ack);
|
p.map(q, p.ack); // hmmm, v8 profiler can't see into this cause of try/catch?
|
||||||
return;
|
return;
|
||||||
}catch(e){ tmp = e }
|
}catch(e){ tmp = e }
|
||||||
if('{' === data[0]){
|
if('{' === data[0]){
|
||||||
@ -382,7 +382,7 @@
|
|||||||
//var i = 0, l = q.length, ack;
|
//var i = 0, l = q.length, ack;
|
||||||
var S = +new Date;
|
var S = +new Date;
|
||||||
var err = p.err, data = p.not? u : p.disk;
|
var err = p.err, data = p.not? u : p.disk;
|
||||||
var i = 0, ack; while(i < 9 && (ack = q[i++])){ ack(err, data, info) }
|
var i = 0, ack; while(i < 9 && (ack = q[i++])){ ack(err, data, info) } // too much?
|
||||||
console.STAT && console.STAT(S, +new Date - S, 'rad packs', ename(file));
|
console.STAT && console.STAT(S, +new Date - S, 'rad packs', ename(file));
|
||||||
console.STAT && console.STAT(S, i, 'rad packs #', ename(file));
|
console.STAT && console.STAT(S, i, 'rad packs #', ename(file));
|
||||||
if(!(q = q.slice(i)).length){ return }
|
if(!(q = q.slice(i)).length){ return }
|
||||||
|
@ -23,7 +23,7 @@ function Store(opt){
|
|||||||
move(tmp, opt.file+'/'+file, cb);
|
move(tmp, opt.file+'/'+file, cb);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
store.get = function(file, cb){ var tmp;
|
store.get = function(file, cb){ var tmp; // this took 3s+?
|
||||||
if(tmp = puts[file]){ cb(u, tmp); return }
|
if(tmp = puts[file]){ cb(u, tmp); return }
|
||||||
fs.readFile(opt.file+'/'+file, function(err, data){
|
fs.readFile(opt.file+'/'+file, function(err, data){
|
||||||
if(err){
|
if(err){
|
||||||
|
8
sea.js
8
sea.js
@ -1148,8 +1148,14 @@
|
|||||||
|
|
||||||
var u;
|
var u;
|
||||||
function check(msg){ // REVISE / IMPROVE, NO NEED TO PASS MSG/EVE EACH SUB?
|
function check(msg){ // REVISE / IMPROVE, NO NEED TO PASS MSG/EVE EACH SUB?
|
||||||
if((msg._||'').faith && (this.as.opt||'').faith && 'function' == typeof msg._){ this.to.next(msg); return }
|
|
||||||
var eve = this, at = eve.as, put = msg.put, soul = put['#'], key = put['.'], val = put[':'], state = put['>'], id = msg['#'], tmp;
|
var eve = this, at = eve.as, put = msg.put, soul = put['#'], key = put['.'], val = put[':'], state = put['>'], id = msg['#'], tmp;
|
||||||
|
if((msg._||'').faith && (at.opt||'').faith && 'function' == typeof msg._){
|
||||||
|
SEA.verify(SEA.opt.pack(put), false, function(data){ // this is synchronous if false
|
||||||
|
put['='] = SEA.opt.unpack(data);
|
||||||
|
eve.to.next(msg);
|
||||||
|
});
|
||||||
|
return
|
||||||
|
}
|
||||||
var no = function(why){ at.on('in', {'@': id, err: why}) };
|
var no = function(why){ at.on('in', {'@': id, err: why}) };
|
||||||
//var no = function(why){ msg.ack(why) };
|
//var no = function(why){ msg.ack(why) };
|
||||||
(msg._||'').DBG && ((msg._||'').DBG.c = +new Date);
|
(msg._||'').DBG && ((msg._||'').DBG.c = +new Date);
|
||||||
|
@ -334,6 +334,35 @@ describe('SEA', function(){
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('save json', function(done){
|
||||||
|
user.get('a').get('c').put(JSON.stringify({hello:'world'}), function(ack){
|
||||||
|
expect(ack.err).to.not.be.ok();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
it('read json', function(done){
|
||||||
|
user.get('a').get('c').once(function(data){
|
||||||
|
expect(data).to.be(JSON.stringify({hello:'world'}));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
it('save & read encrypt', function(done){
|
||||||
|
SEA.encrypt('hi', user._.sea, function(data){
|
||||||
|
var is = data.slice();
|
||||||
|
user.get('a').get('d').put(data, function(ack){
|
||||||
|
expect(ack.err).to.not.be.ok();
|
||||||
|
setTimeout(function(){
|
||||||
|
user.get('a').get('d').once(function(data){
|
||||||
|
expect(data).to.be(is);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('refresh login', function(done){
|
it('refresh login', function(done){
|
||||||
this.timeout(9000);
|
this.timeout(9000);
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user