示例#1
0
    def finish_post_set(self):
        account_update_list = []  # calculates the total votes of each post
        for i in self.post_list:
            votes = 0
            for vote in i[2]:
                if vote[1] == 1:
                    in_list = False
                    for ii in account_update_list:
                        if ii[0] == vote[0]:
                            in_list = True
                            ii[1].append(i[0])
                            break

                    votes += 1

            # Make post memo, link to in vote memo

            memo_pos = interpret.vote_post(i[0], i[1], i[4], votes / len(i[2]),
                                           self.memo_account,
                                           self.sending_account, self.key)
            for ii in i[2]:
                interpret.update_account(
                    ii[0], self.sending_account,
                    self.memo_account["vote",
                                      str(ii[1]) + "|" + str(memo_pos)],
                    self.key)

            self.votes_finished = True
    def buy_token(self, account, token, amount):

        self.token_prices = {
            "token-upvote-perm": 0.5,
            "ad-token-perm": 0.75,
            "adp_tok": 0.05
        }

        try:
            account = interpret.get_account_info(account, self.active_key,
                                                 self.sending_account,
                                                 self.memo_account,
                                                 self.steem_node)
            print(27)
            # Checks if the account has enough GP to buy the tokens, if it does update the account with the new amount
            if account[2]["gp"] > self.token_prices[token] * amount:
                print(28)
                interpret.update_account(
                    account, self.sending_account, self.memo_account, [[
                        "gp",
                        account[2]["gp"] - self.token_prices[token] * amount
                    ], [token, account[2][token] + amount]], self.active_key,
                    self.steem_node)

            else:
                print(29)
                return False
            #elif account[2]["gp"] + account[2]["steem-owed"] > self.token_prices[token] * amount:
            #   interpret.update_account(self.user_info["steem-account"])
            print(account)
            return account
        except Exception as e:
            print(e)
            return False
示例#3
0
    def make_purchase(self, token, amount):
        # This takes GP the user has and buys a Token from it.
        try:
            account = interpret.get_account_info(
                self.user_info["steem-account"], self.main.active_key,
                self.main.sending_account, self.main.memo_account,
                self.steem_node)
            print(27)
            # Checks if the account has enough GP to buy the tokens, if it does update the account with the new amount
            if account[2]["gp"] > self.token_prices[token] * amount:
                print(28)
                interpret.update_account(
                    self.user_info["steem-account"], self.main.sending_account,
                    self.main.memo_account, [[
                        "gp",
                        account[2]["gp"] - self.token_prices[token] * amount
                    ], [token, account[2][token] + amount]],
                    self.main.active_key, self.main.steem_node)

            else:
                print(29)
            #elif account[2]["gp"] + account[2]["steem-owed"] > self.token_prices[token] * amount:
            #   interpret.update_account(self.user_info["steem-account"])
            print(account)
            return account
        except Exception as e:
            print(e)
            return False
示例#4
0
    def get_ratio(self,vote_list):
        vote_rating = [0,0]
        change_rating = [0,0]
        accounts = {}
        if vote_list < 2:
            return [0,0]
        for i in vote_list:
            account_info = interpret.get_account_info(i[0],self.main.active_key, self.main.sending_account, self.main.memo_account,
                                                       self.main.nodes[0])[2]
            curation_rating = account_info["rating_curation"]
            accounts[account_info["steem-name"]] = account_info
            vote_rating[0] += (curation_rating ** 2) * i[1]
            vote_rating[1] += curation_rating ** 2
            for ii in account_info["groups"]:
                if ii[0] == "CI":
                    rating_change_val = ii[1]
                change_rating[0] += (curation_rating ** 2) * i[1] * rating_change_val
                change_rating[1] += (curation_rating ** 2) * rating_change_val
        for i in vote_list:
            for ii in account_info[i[0]]["groups"]:
                if ii[0] == "CI" and ii[1] < 3:
                    new_rating = account_info[i[0]]["rating_curation"] + (1/1000) * ((change_rating[0]/change_rating[1])
                                                                                                 - self.ratio_num) * i[1]

                    interpret.update_account(i[0],self.main.sending_account,self.main.memo_account,["rating_curation",new_rating],self.main.key,self.main.nodes[0])
        return vote_rating
示例#5
0
def deposit(info,node):

    # Takes a deposit of sbd and adds it in as GP and sends it as a new account memo
    global sending_account, memo_account, active_key
    print(info)
    account_info = interpret.get_account_info(info["from"], active_key, sending_account, memo_account,
                               node)[2]
    print(float(info["amount"].split(" STEEM")[0]))

    interpret.update_account(info["from"], sending_account, memo_account, [["gp",account_info["gp"] + float(info["amount"].split(" STEEM")[0])]],
                             active_key, node)
示例#6
0
    def add_post(self, post_link, submission_author):
        print("START ADD POST")
        with self.lock:
            for i in self.post_list:
                if submission_author == i[1]:
                    return False
            submission_acc = interpret.get_account_info(submission_author,self.key,self.sending_account,self.memo_account,self.nodes[0])
            if submission_acc[2]["adp_tok"] > 0:
                print("UPDATE 2nd")
                interpret.update_account(submission_author,self.sending_account,self.memo_account,[["adp_tok", submission_acc[2]["adp_tok"] - 1]], self.key,self.nodes[0])
            else:
                return False
            print("update 3rd")

        #https://steemit.com/politics/@anarchyhasnogods/a-communist-definition-of-property
        # example post link
            new_link = post_link.split("@")
            perm_link = new_link[1].split("/") # brings it to ["author","permlink"]

        # post_list = [[postname, submission author, vote list, advertisement_total]]

        # gets account info for reward calculation
            account_info_post = interpret.get_account_info(perm_link[1],self.main.active_key,self.main.sending_account,self.main.memo_account,self.main.nodes[0])
            print("ACCOUNT INFO POST")

            if account_info_post != None:
                account_info_post = account_info_post[2]
                ad_tokens = int(account_info_post["ad-token-perm"])  # + int(account_info_post["ad-token-temp"])
            else:
                ad_tokens = 0

        # uses add tokens to calculate visibility within system, and save information needed for later.
            self.post_list.append([post_link, submission_author, [], 10 + int(math.sqrt(ad_tokens)), time.time(), perm_link])
            print(self.post_list)
            self.set_random(already_locked=True)
        return True
def curation_rewards(sending_account,memo_account,active_key,time_period,node):
    # gets full list of curation rewards, then full list of posts through our system
    # looks to see if post is in the post_list, if it is it adds some of the reward to every account involved
    reward_list = interpret.get_all_curation_rewards(time_period,sending_account,memo_account,node)
    print(reward_list)
    print("REWARD LIST")
    post_list = interpret.get_all_votes(time_period * 5,sending_account,memo_account,node)


   # print(post_list)


    for reward in reward_list:
        print("REWARD")
        print(reward)
        for post in post_list:

            try:
                post[2] = json.loads(post[2])
            except Exception as e:

                pass
            print("POST LIST")
            print(post[2]["post_link"].split("/")[4]+"/"+ post[2]["post_link"].split("/")[5],"@"+reward[1]["comment_author"] +"/" + reward[1]["comment_permlink"])
            if post[2]["post_link"].split("/")[4]+"/"+ post[2]["post_link"].split("/")[5] == "@"+reward[1]["comment_author"] +"/" + reward[1]["comment_permlink"]:
                print(2)
                for vote in post[2]["vote-list"]:
                    print(1)
                    account = interpret.get_account_info(vote[0],active_key,sending_account,memo_account,node)
                    if account != None and account != []: # checks that its an actual account, for testing
                        # checks through all votes made by the account
                        # The vote is added to the account only after it is added to the reward total
                        already_voted = False


                        # goes through every vote made by the account to see if the saved position of the post-memo is the same as where it was found
                        # if no matching vote is found, a vote is added and rewards are adjusted
                        for account_vote in account[2]["vote"]:
                            print("ACCOUNT VOTE")
                            if already_voted:
                                break

                            if post[0] == account_vote[0]:

                                already_voted = True
                            pass

                        for post_link in account[2]["vote-link"]:
                            if already_voted:
                                break
                            post_link = interpret.vote_link_find(post_link[0],post_link[1],sending_account,node)
                            print(post_link)
                            for post_vote in json.loads(post_link[0][2])["vote"]:
                                if already_voted:
                                    break
                                if post[0] == post_vote[0]:
                                    already_voted = True
                            print("end")
                        print("HEREEE")
                        if not already_voted:
                            submitor_val = 0
                            if account[2]["account"] == post[2]["submission_author"]:
                                submitor_val = 0.1
                            print("not already voted")
                            steem_value = steem.converter.Converter().vests_to_sp(float((reward[1]["reward"].split(" VESTS")[0])))/ (len(post[2]["vote-list"]))
                            print(steem_value)
                            steem_value += steem.converter.Converter().vests_to_sp(float((reward[1]["reward"].split(" VESTS")[0]))) * submitor_val
                            print(1111)
                            try:
                                print(account[2])
                                interpret.update_account(account[2]["account"], sending_account, memo_account,
                                                     [["vote",[post[0],memo_account]],["gp",account[2]["gp"] + steem_value * account[2]["steem-gp-ratio"] * account[2]["rating_curation"]],
                                                      ["steem-owed",account[2]["steem-owed"] + steem_value * (1-account[2]["steem-gp-ratio"]) * account[2]["rating_curation"]]], active_key,node)
                                time.sleep(3)
                            except Exception as e:
                                print(e)
                                print("err -1")

                        else:
                            print("already voted")
    return


    pass