Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. # tip selection pseudocode
  2. def pick_tip(tangle, tips):
  3. tovisit = queue(tips.copy())
  4.  
  5. while !tovisit.empty():
  6. tx = tovisit.poll()
  7. tx.weight = sum(tx.approvees.weights) + 1
  8. if tx.depth < maxdepth:
  9. tovisit.push(tx.branch, tx.trunk)
  10.  
  11. walktx = random tx in tangle where depth == maxdepth
  12. while walktx not in tips:
  13. walktx = weighted_random(walktx.approvees)
  14.  
  15. return walktx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement