Exemplo n.º 1
0
    def get_history(self, username):
        a = Account(username)
        history = a.history_reverse()
        count = 1

        for item in history:
            if count > 3:
                break
            print(item)
            count = count + 1
Exemplo n.º 2
0
    def get_latest_flags(self):
        flags = {}
        total_amount = 0
        account = Account(self.account_for_flag_report,
                          steemd_instance=self.steemd_instance)
        for vote in account.history_reverse(filter_by="vote"):
            if vote["weight"] > 0:
                continue
            if vote["voter"] != self.account_for_flag_report:
                continue
            ts = parse(vote["timestamp"])
            if ts < (datetime.utcnow() - timedelta(days=1)):
                break

            try:
                p = Post("%s/%s" % (vote["author"], vote["permlink"]),
                         steemd_instance=self.steemd_instance)
            except steembase.exceptions.PostDoesNotExist:
                logger.info("Couldnt load the post. %s" % vote["permlink"])
                continue

            if vote["author"] not in flags:
                flags[vote.get("author")] = {
                    "posts": 0,
                    "comments": 0,
                    "total_removed": 0
                }

            if p.is_main_post():
                flags[vote.get("author")].update(
                    {"posts": flags[vote.get("author")]["posts"] + 1})
            else:
                flags[vote.get("author")].update(
                    {"comments": flags[vote.get("author")]["comments"] + 1})

            logger.info("Analyzing %s" % self.url(p))

            for active_vote in p.get("active_votes"):
                if float(active_vote.get("rshares")) > 0:
                    continue

                if active_vote.get("voter") != self.account_for_flag_report:
                    continue

                amount_removed = self.get_payout_from_rshares(
                    active_vote.get("rshares"))
                total_amount += amount_removed

                flags[vote.get("author")].update({
                    "total_removed":
                    flags[vote.get("author")]["total_removed"] +
                    amount_removed,
                })

        return flags, round(total_amount, 2)
Exemplo n.º 3
0
def test_history():
    a = Account('barbara2')
    h1 = [x['index'] for x in list(a.history())]
    h2 = [x['index'] for x in list(a.history_reverse())]

    # pprint(list(zip(h1, h2[::-1])))

    # various tests of equality should pass
    assert len(h1) == len(h2)
    assert set(h1) == set(h2) == set(range(a.virtual_op_count() + 1))
    assert h1 == h2[::-1] == list(range(a.virtual_op_count() + 1))
Exemplo n.º 4
0
def calculate_producer_rewards(steemd_instance, witness_account):
    account = Account(witness_account, steemd_instance=steemd_instance)

    total_vests = 0

    for producer_reward in account.history_reverse(
            filter_by=["producer_reward"]):
        total_vests += Amount(producer_reward["vesting_shares"]).amount

    converter = Converter(steemd_instance=s)
    total_sp = converter.vests_to_sp(total_vests)

    return total_vests, total_sp
Exemplo n.º 5
0
    def last_voted_accounts_and_posts(self):
        voted_accounts = set()
        voted_posts = set()
        account = Account(self.config.get("BOT_ACCOUNT"))
        vote_interval = self.config.get("VOTE_INTERVAL_IN_DAYS", 1)
        for vote in account.history_reverse(filter_by=["vote"]):
            created_at = parse(vote["timestamp"])
            if created_at < (datetime.utcnow() -
                             timedelta(days=vote_interval)):
                break
            voted_accounts.add(vote["author"])
            voted_posts.add("@%s/%s" % (vote["author"], vote["permlink"]))

        return voted_accounts, voted_posts
Exemplo n.º 6
0
def test_history():
    # TODO 1: test is disabled because api.steemit.com account history
    #         pruning is temporarily in place, breaking assumptions.
    # TODO 2: in addition, the current pruning implementation fails
    #         to remove the very first operation, revealing a bug in
    #         history_reverse() which causes it to be included once
    #         on every page, causing an item count mismatch.
    return

    a = Account('barbara2')
    h1 = [x['index'] for x in list(a.history())]
    h2 = [x['index'] for x in list(a.history_reverse())]

    # pprint(list(zip(h1, h2[::-1])))

    # various tests of equality should pass
    assert len(h1) == len(h2)
    assert set(h1) == set(h2) == set(range(a.virtual_op_count() + 1))
    assert h1 == h2[::-1] == list(range(a.virtual_op_count() + 1))
Exemplo n.º 7
0
def find_last_index(U):
    for u in U:
        a = Account(u['id'])
        for comment in a.history_reverse(filter_by="comment"):
            u['last_index'] = comment['index']
            break
Exemplo n.º 8
0
Arquivo: gtw.py Projeto: DoctorLai/gtw
	exit()

password="******"
os.environ["UNLOCK"] = password
user = username
block_file="gtw_blocks.txt"
lb=1
with open(block_file, 'r') as f:
	for line in f.readlines():
		lb = int(line)

mlb = lb
ac = Account(user,s)
block_witness={}
transfers = []
hrl = ac.history_reverse(filter_by='transfer',raw_output=False)

for op in hrl:
	if op['block'] <= lb:
		break
	block_num = op['block']
	if op['block'] > mlb:
		mlb = op['block']
		with open(block_file, 'a+') as f:
			f.write("%s\n" % str(mlb))
	am = Amount(op['amount'])
	if am.amount==0.002 and am.asset=='SBD' and op['to']==username:
		if block_num not in block_witness:
			get_witness(block_num,block_witness,s)
		guess = op['memo'].strip('@')
		if guess == block_witness[block_num]:
Exemplo n.º 9
0
from steem.account import Account
from pymongo import MongoClient
from datetime import datetime, timedelta

from voter.config import CONFIG
from steevebase.io import update_data_db
import steevebase.io as io

CURATOR = 'hr1'


def parse_op(op):
    op['timestamp'] = datetime.strptime(op['timestamp'], '%Y-%m-%dT%H:%M:%S')
    return op


DB_ADDRESS = CONFIG['DATABASE']['ADDRESS']
db = io.mongo_factory(DB_ADDRESS)
monitor_col = db.get_collection("monitor")

steem = io.steem_factory()
acc = Account(CURATOR, steemd_instance=io.steemd_instance)
ops = ['claim_reward_balance', 'transfer_to_vesting',
       'fill_vesting_withdraw']  # 'curation_reward'
history = acc.history_reverse(filter_by=ops, batch_size=1000)

for op in history:
    op = parse_op(op)
    # monitor_col.insert_one(op)
    update_data_db(db, monitor_col, op)