git ssb

6+

Dominic / epidemic-broadcast-trees



Commit 36fd23a2593c35e462fe4c1a3ff057b0a4dafa83

set local state, and batch mode requests

Dominic Tarr committed on 6/5/2017, 11:39:36 AM
Parent: b1d492d4ce5e4a3cf220de4e978b82450fc9a3df

Files changed

index.jschanged
index.jsView
@@ -186,17 +186,24 @@
186186 },
187187 onAppend: function (msg) {
188188 var k = msg.author
189189 //TMP, call a user provided function to decide how to handle this.
190- if(!states[k]) maybeQueue(k, states[k] = S.init(msg.sequence))
190 +// if(!states[k]) {
191 +// console.log('ON_APPEND', msg.author, msg.sequence)
192 +// maybeQueue(k, states[k] = S.init(msg.sequence))
193 +// }
194 +//
191195 if(states[k]) {
192196 maybeQueue(k, states[k] = S.appendMessage(states[k], msg))
193197 checkNote(k)
194198 next()
195199 }
196200 },
197- request: function (id, seq) {
201 + //but what if you want to push in a bunch
202 + //of items but not trigger next just yet?
203 + request: function (id, seq, isSingle) {
198204 //only allow updates if it's gonna change the state.
205 + //this section should move into state.js
199206 if(!states[id]) {
200207 states[id] = S.init(seq)
201208 readyNote[id] = true
202209 }
@@ -204,14 +211,19 @@
204211 states[id].local.seq == null ||
205212 states[id].local.seq == -1 ||
206213 (seq === -1 && states[id].local.seq != -1)
207214 ) {
215 + //MUST set the local state, otherwise receiveMessage won't work.
216 + if(seq >= 0) states[id].local.seq = seq
208217 states[id].ready = seq
209218 readyNote[id] = true
210- next()
219 + if(isSingle !== false) {
220 + next()
221 + }
211222 }
212223 },
213- states: states
224 + states: states,
225 + next: next
214226 }
215227
216228 if(opts.seqs) {
217229 for(var k in opts.seqs)
@@ -221,5 +233,4 @@
221233
222234 }
223235 }
224236
225-

Built with git-ssb-web