Skip to content

Instantly share code, notes, and snippets.

@mgraczyk
Created June 28, 2018 23:17
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/bca7db5d7a81993ad24baef8f096072a to your computer and use it in GitHub Desktop.
Save mgraczyk/bca7db5d7a81993ad24baef8f096072a to your computer and use it in GitHub Desktop.
func (n *Node) OnReceiveTx(tx *Transaction) bool {
// ... Verify tx
// [OT] Take a global read lock.
mutex.Lock()
defer mutex.Unlock()
// [OT] Line 9
if _, received := n.Transactions[tx.Id]; !received {
// [OT] Line 10
if set, exists := n.Conflicts[tx.Body.Utxo]; exists {
set.Transactions[tx.Id] = tx // [OT] Line 13
} else {
// [OT] Lines 11/12
n.Conflicts[tx.Body.Utxo] = CreateConflictSet(tx)
}
// [OT] Line 14
n.Transactions[tx.Id] = tx
n.Chits[tx.Id] = 0
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment