def get_account_list(sending_account, memo_account_list, node, days=365): block = days * 24 * 60 * 20 # checks up to 7 days ago by default memo_list = [] temp_list = [] accounts_in_list = {"accounts": []} for i in memo_account_list: print("XX7") temp_list.append( main.retrieve([["type", "account"]], sending_account, i, not_all_accounts=False, minblock=block, node=node)) for ii in temp_list[0]: ii[2] = json.loads(ii[2]) if ii[2]["account"] not in accounts_in_list["accounts"]: accounts_in_list["accounts"].append(ii[2]["account"]) accounts_in_list[ii[2]["account"]] = ii elif accounts_in_list[ii[2]["account"]][3] > ii[3]: accounts_in_list[ii[2]["account"]] = ii # Account_in_list is a dictionary, "accounts" is a list of accounts. Each account has its full account memo info in the dict under its account name # to go through info in accounts iterate through the account list as dictionary keys return accounts_in_list
def get_vote_list(memo_account, sending_account, post_link, node): print("XX3") return_info = main.retrieve(keyword=[["vote-link", post_link]], account=sending_account, sent_to=memo_account, node=node) return return_info
def vote_link_find(position, our_memo_account, our_sending_account, node): print("XX2") return_info = main.retrieve(position=position, account=our_sending_account, sent_to=our_memo_account, node=node) return return_info
def get_account_info(account, our_account="anarchyhasnogods", our_memo_account="space-pictures"): return_info = main.retrieve(["account", account], account=our_account, sent_to=our_memo_account) return return_info[0]
def get_all_curation_rewards(time_period, our_account, our_memo_account, node): block = time_period / 3 print("XX5") return_info = main.retrieve(account=our_account, sent_to=our_memo_account, node=node, minblock=block, not_all_accounts=False, type_thing="curation_reward") return return_info pass
def get_all_votes(time_period, our_account, our_memo_account, node): block = time_period / 3 print("XX5") return_info = main.retrieve([["type", "post"]], account=our_account, sent_to=our_memo_account, node=node, minblock=block, not_all_accounts=False) return return_info pass
def get_all_accounts(sending_account, memo_account, node, days=31): block = days * 24 * 60 * 20 print("XX1") return_info = main.retrieve([["type", "account"]], sending_account, memo_account, not_all_accounts=False, minblock=block, node=node) account_list = [] return_list = [] for i in return_info: if not json.loads(i[2])["account"] in account_list: account_list.append(json.loads(i[2])["account"]) return_list.append(i) return return_list pass
def get_account_info(account, active_key, our_account="anarchyhasnogods", our_memo_account="space-pictures", node="wss://steemd-int.steemit.com"): # gets the useful account info for a specific account, goes through all accounts until it gets the correct account then returns info #print("getting account info") print("XX6") print(account, our_account, our_memo_account) return_info = main.retrieve([["account", account], ["type", "account"]], account=our_account, sent_to=our_memo_account, node=node) if return_info != []: return_info[0][2] = update_info_version(json.loads(return_info[0][2]), active_key, our_account, our_memo_account, node) return return_info[0] return None
def get_vote_amount(time_period, our_account="anarchyhasnogods", our_memo_account="space-pictures", node="wss://steemd-int.steemit.com"): # time period is seconds # gets average vote size by our account on posts over the time period, using the post memos sent block = time_period / 3 print("XX4") return_info = main.retrieve([["type", "post"]], account=our_account, sent_to=our_memo_account, node=node, minblock=block, not_all_accounts=False) vote_power_in_period = (1000 / (24 * 60 * 60)) * time_period average_ratio = [0, 0] for i in return_info: try: if float(json.loads(i[2])["vote_size"] != 0): average_ratio[0] += float(json.loads(i[2])["ratio"]) average_ratio[1] += 1 except KeyError: pass if average_ratio[1] != 0: average_ratio = average_ratio[0] / average_ratio[1] else: return [vote_power_in_period, 1] #print("RETURN INFO") #print("RETURN INFO LENGTH: ", average_ratio, len(return_info)) #print(vote_power_in_period) if len(return_info) == 0: return [vote_power_in_period, 1] return [vote_power_in_period / len(return_info), average_ratio]
def fix_memo(self, memo_list): # takes memos and checks if any overwrote the changes of the other # this can happen if the memos come at intervals that are too close together print("FIXING MEMOs") print(memo_list) highest_version = -1 same_version = False memos_to_fix = [] for i in memo_list: print(i["version"], i) if i["version"] == highest_version: print("SAME VERSION") same_version = True memos_to_fix.append(i) elif i["version"] > highest_version: highest_version = i["version"] memos_to_fix = [i] if not same_version: print("RETURNING") return changes = [] og_memo_num = 0 for i in memos_to_fix: for ii in i["changes"]: append_to = True for iii in changes: if iii[0] == ii[0] and iii[1] == ii[1]: append_to = False if append_to: changes.append(ii) print("CHANGES") print(changes) if len(changes) < 2 or len(changes) == len(memos_to_fix[0]["changes"]): print("returning before memo") return try: oldest = 0 for i in memos_to_fix: if i["old"] > oldest: oldest = i["old"] except Exception as e: print(e) memo = json.loads( main.retrieve(account=self.main_account, sent_to=self.memo_account, position=oldest, node=self.node)[0][2]) print("MEMO") print(memo) for i in memo: rel_changes = [] for ii in changes: if i == ii[0]: rel_changes.append(ii) print("REL CHANGES APPEND") if len(rel_changes) > 1: if rel_changes[0][0] == "vote": for c in rel_changes: memo["vote"].append(c[1]) elif rel_changes[0][0] == "groups": pass elif rel_changes[0][0] == "vote-link": for c in rel_changes: memo["vote-link"].append(c[1]) else: for c in rel_changes: memo[c[0]] += memo[c[0]] - c[1] elif len(rel_changes) < 1: pass else: memo[rel_changes[0][0]] = rel_changes[0][1] memo["version"] = highest_version + 1 print(memo) memo["changes"] = changes main.save_memo(memo, self.memo_account, self.main_account, self.active_key, node=self.node)