def followvote(op): if op['weight'] <= 1 or op['voter'] not in follow or op[ 'author'] in except_authors or op['author'] == op['voter'] or ( op['voter'] in clones and op['author'] in clones[op['voter']]): return False print("Valid vote found by " + op['voter'] + " (" + str(op['weight']) + ")") postid = '@' + op['author'] + '/' + op['permlink'] post = client.get_post(postid) dovote = True for v in post['active_votes']: if v['voter'] == votewith: print('already voted on ' + postid) dovote = False if dovote == True and (str(post['last_payout']) != '1970-01-01 00:00:00' or post['max_accepted_payout'] == Amount('0.000 SBD')): print(postid + ' is not a curation rewarding post') dovote = False if dovote == True: fweight = follow[op['voter']] weight = fweight if op['weight'] == 0: weight = 0 elif fweight < 1: weight = math.ceil(op['weight'] * fweight) / 100 if weight >= 0: if weight == 0.01: weight = 0.02 nop = transactions.Vote( **{ "voter": votewith, "author": op["author"], "permlink": op["permlink"], "weight": int(weight * 100) }) castvote(transactions.Operation(nop)) print('Voted on ' + postid + ' following ' + op["voter"] + ' with ' + str(weight) + '%') try: with conn: c.execute( '''INSERT OR IGNORE INTO votes (postid, weight, voter, reward) VALUES (?,?,?,?)''', ( postid, weight, op['voter'], 0, )) except: print('vote not saved')
def proceed(op): expiration = transactions.formatTimeFromNow(60) ops = [transactions.Operation(op)] ref_block_num, ref_block_prefix = transactions.getBlockParams(rpc) tx = transactions.Signed_Transaction(ref_block_num=ref_block_num, ref_block_prefix=ref_block_prefix, expiration=expiration, operations=ops) tx = tx.sign([wif]) # Broadcast JSON to network rpc.broadcast_transaction(tx.json(), api="network_broadcast")
def transfer(sender, recipient, amount, memo): expiration = transactions.formatTimeFromNow(60) op = transactions.Transfer(**{ "from": sender, "to": recipient, "amount": amount, "memo": memo }) ops = [transactions.Operation(op)] ref_block_num, ref_block_prefix = transactions.getBlockParams(rpc) tx = transactions.Signed_Transaction(ref_block_num=ref_block_num, ref_block_prefix=ref_block_prefix, expiration=expiration, operations=ops) tx = tx.sign([wif]) # Broadcast JSON to network rpc.broadcast_transaction(tx.json(), api="network_broadcast")