Skip to content

Commit

Permalink
Fix: in-order delivery callback also receives log entries with incomp…
Browse files Browse the repository at this point in the history
…lete sidechains
  • Loading branch information
jannickheisch committed Dec 10, 2023
1 parent ec0765a commit 036a4b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion android/tinySSB/app/src/main/assets/web/tremola.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ function b2f_local_peer(type, identifier, displayname, status) {
*/
function b2f_new_in_order_event(e) {

console.log("b2f inorder event")
console.log("b2f inorder event:", JSON.stringify(e.public))

if (!(e.header.fid in tremola.contacts)) {
var a = id2b32(e.header.fid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class WebAppInterface(val act: MainActivity, val webView: WebView) {
for (i in seq .. replica.state.max_seq ) {
val content = replica.read(i)
val message_id= replica.get_mid(seq)
if(content == null || message_id == null)
if(content == null || message_id == null || !replica.isSidechainComplete(i))
break
e = toFrontendObject(fid, i, message_id, content)
if (e != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,9 @@ class Replica(val context: MainActivity, val datapath: File, val fid: ByteArray)
Log.d("replica", "write success, len: ${log_entry.size}")
return seq
}

fun isSidechainComplete(seq: Int): Boolean {
return !state.pend_sc.containsKey(seq)
}

}

0 comments on commit 036a4b3

Please sign in to comment.