Skip to content

Instantly share code, notes, and snippets.

@mgraczyk
Created June 28, 2018 23:19
Show Gist options
  • Save mgraczyk/290d584001fa05d23a198b1ad207c944 to your computer and use it in GitHub Desktop.
Save mgraczyk/290d584001fa05d23a198b1ad207c944 to your computer and use it in GitHub Desktop.
func QueryEvents(n *Node, rpc RPC) {
// [OT] Line 2 with modified condition
for id, tx := range n.Unqueried() {
// [OT] Check that the transactions parents are known
// In a real implementation, undigestible txns
// would eventually need to be pruned.
if !n.IsDigestable(tx) {
continue
}
// [OT] Lines 4-5
positiveResponses, threshold := rpc.QueryNodesForTx(tx, K), Alpha*K
// [OT] Line 6 (does not match paper)
if positiveResponses < int(threshold) {
continue
}
// [OT] Line 7
mutex.Lock()
n.Chits[id] = 1
mutex.Unlock()
// ... Lines 8-15, update the preferences for ancestors
// ... Logging
// [OT] Line 17
mutex.Lock()
n.Queried[id] = tx
mutex.Unlock()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment