Skip to content

Instantly share code, notes, and snippets.

@mgraczyk
Created June 28, 2018 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgraczyk/3bd7e5bb8e91470b444acac6b60fe355 to your computer and use it in GitHub Desktop.
Save mgraczyk/3bd7e5bb8e91470b444acac6b60fe355 to your computer and use it in GitHub Desktop.
// ... update the preference for ancestors
// [OT] This only loops over parents, not ancestors
for _, parentId := range tx.Body.Parents {
mutex.RLock()
parent := n.Transactions[parentId]
conflicts := n.Conflicts[parent.Body.Utxo]
mutex.RUnlock()
parentScore, presentScore := n.Confidence(parent), n.Confidence(conflicts.Preferred)
if parentScore > presentScore {
conflicts.Preferred = parent
} else if parent != conflicts.Last {
conflicts.Last = parent
conflicts.Count = 0
} else {
conflicts.Count++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment