Skip to content

Commit

Permalink
start of optmizing stamp reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim de Beer committed Sep 25, 2016
1 parent eb33f55 commit c6a230e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
16 changes: 15 additions & 1 deletion lib/receive.js
Expand Up @@ -22,7 +22,21 @@ exports.define = {
console.log('RECIEVE', hub.incomingStamp)

// update to the top
hub.emit('subscription', hub.incomingStamp)

console.log(hub.incomingStamp.path)

if (hub.incomingStamp) {
const field = hub.get(hub.incomingStamp.path)
var parent = field
while (parent) {
// may need to create context
parent.stamp = hub.incomingStamp.stamp
parent = parent.parent
}
hub.emit('subscription', data.state, hub.incomingStamp.stamp)
} else {
hub.emit('subscription')
}

hub.set({ incomingStamp: false }, false)
}
Expand Down
8 changes: 4 additions & 4 deletions lib/sync/set.js
Expand Up @@ -33,12 +33,12 @@ exports.define = {

if (
!prevIncoming ||
Number(vstamp.val(prevIncoming)) < Number(vstamp.val(t))
Number(vstamp.val(prevIncoming.stamp)) < Number(vstamp.val(t))
) {
console.log('ok bigger then the last one')
console.log(' ok bigger then the last one')
if (!block) {
console.log(this.path(), t)
this.root.incomingStamp = t
console.warn(' ', this.realPath().join('.'), '->', t)
this.root.incomingStamp = { stamp: t, path: this.realPath() }
} else {
console.log('but not passing... (block:true)')
}
Expand Down
7 changes: 7 additions & 0 deletions lib/sync/subscription/index.js
Expand Up @@ -45,6 +45,13 @@ exports.define = {
clients = [client]

update = function (state, type, stamp, subs, tree, sType) {
// how to know what the state was on remove :/ fucked up
// console.log('????', type, sType, subs)

// console.log(tree)
// big problem...

// really need the state :/
if (state.syncDown) {
const stamp = state.stamp
if (stamp) {
Expand Down

0 comments on commit c6a230e

Please sign in to comment.