Skip to content

Instantly share code, notes, and snippets.

@mgraczyk

mgraczyk/perlin7.go

Created Jun 28, 2018
Embed
What would you like to do?
func (n *Node) IsStronglyPreferred(tx *Transaction) bool {
mutex.RLock()
defer mutex.RUnlock()
stronglyPreferred := true
parents := // ... make map of parent ids
for len(parents) != 0 {
for parentId := range parents {
// [OT] stronglyPreferred could be memoized here for efficiency
// This is a downside of using protocol buffers for state.
// Additional in-memory state can't be stored naturally because
// we don't want to transmit stronglyPreferred over the wire.
if // ... parent exists {
// [OT] Line 2, isPreferred
stronglyPreferred = stronglyPreferred && n.Conflicts[parent.Body.Utxo].Preferred == parent
ancestors := // ... make map of ancestor hashes
}
// ... Handle parent doesn't exist
}
// [OT] Recursion on ancestors
parents = ancestors
}
return stronglyPreferred
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.