Created
June 28, 2018 23:18
-
-
Save mgraczyk/c2ed25bace5068cabb900c79224e296c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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