Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json, re, requests, collections
- from piston.steem import Steem
- def extraction(random, votes):
- tot_rshares = sum(map(int,[x['rshares'] for x in votes]))
- tickets = {}
- for vote in votes:
- tickets[vote['voter']] = float(vote['rshares'])/tot_rshares
- tot = 0
- for voter in collections.OrderedDict(sorted(tickets.items())):
- tot += tickets[voter]
- if tot > random:
- return(voter)
- blockhash = json.loads((requests.get('https://blockchain.info/it/block-height/422321?format=json').text))['blocks'][0]['hash']
- random = int(blockhash,16)/16.**(64-len(re.match('[0]*',blockhash).group(0)))
- votes = Steem().get_content("@rodomonte/social-attack-on-steemit").active_votes
- print(extraction(random, votes))
Advertisement
Add Comment
Please, Sign In to add comment