Example #1
0
 def test_comment(self, node_param):
     if node_param == "non_appbase":
         bts = self.bts
     else:
         bts = self.appbase
     with self.assertRaises(exceptions.ContentDoesNotExistsException):
         Comment("@abcdef/abcdef", steem_instance=bts)
     c = Comment(self.authorperm, steem_instance=bts)
     self.assertTrue(isinstance(c.id, int))
     self.assertTrue(c.id > 0)
     self.assertEqual(c.author, self.author)
     self.assertEqual(c.permlink, self.permlink)
     self.assertEqual(c.authorperm, self.authorperm)
     self.assertEqual(c.category, self.category)
     self.assertEqual(c.parent_author, '')
     self.assertEqual(c.parent_permlink, self.category)
     self.assertEqual(c.title, self.title)
     self.assertTrue(len(c.body) > 0)
     self.assertTrue(isinstance(c.json_metadata, dict))
     self.assertTrue(c.is_main_post())
     self.assertFalse(c.is_comment())
     if c.is_pending():
         self.assertFalse(
             (c.time_elapsed().total_seconds() / 60 / 60 / 24) > 7.0)
     else:
         self.assertTrue(
             (c.time_elapsed().total_seconds() / 60 / 60 / 24) > 7.0)
     self.assertTrue(isinstance(c.get_reblogged_by(), list))
     self.assertTrue(len(c.get_reblogged_by()) > 0)
     self.assertTrue(isinstance(c.get_votes(), list))
     if node_param == "appbase":
         self.assertTrue(len(c.get_votes()) > 0)
         self.assertTrue(isinstance(c.get_votes()[0], Vote))
Example #2
0
 def test_comment(self):
     bts = self.bts
     with self.assertRaises(exceptions.ContentDoesNotExistsException):
         Comment("@abcdef/abcdef", steem_instance=bts)
     title = ''
     cnt = 0
     while title == '' and cnt < 5:
         c = Comment(self.authorperm, steem_instance=bts)
         title = c.title
         cnt += 1
         if title == '':
             c.blockchain.rpc.next()
             c.refresh()
             title = c.title
     self.assertTrue(isinstance(c.id, int))
     self.assertTrue(c.id > 0)
     self.assertEqual(c.author, self.author)
     self.assertEqual(c.permlink, self.permlink)
     self.assertEqual(c.authorperm, self.authorperm)
     # self.assertEqual(c.category, self.category)
     self.assertEqual(c.parent_author, '')
     # self.assertEqual(c.parent_permlink, self.category)
     # self.assertEqual(c.title, self.title)
     self.assertTrue(len(c.body) > 0)
     self.assertTrue(isinstance(c.json_metadata, dict))
     self.assertTrue(c.is_main_post())
     self.assertFalse(c.is_comment())
     if c.is_pending():
         self.assertFalse(
             (c.time_elapsed().total_seconds() / 60 / 60 / 24) > 7.0)
     else:
         self.assertTrue(
             (c.time_elapsed().total_seconds() / 60 / 60 / 24) > 7.0)
     # self.assertTrue(isinstance(c.get_reblogged_by(), list))
     # self.assertTrue(len(c.get_reblogged_by()) > 0)
     votes = c.get_votes()
     self.assertTrue(isinstance(votes, list))
     self.assertTrue(len(votes) > 0)
     self.assertTrue(isinstance(votes[0], Vote))
Example #3
0
                posts = []
                for op in ops[::-1]:
                    try:
                        comment = (json.loads(op["op_dict"]))
                        created = formatTimeString(comment["timestamp"])
                    except:
                        op_dict = op["op_dict"]
                        comment = json.loads(op_dict[:op_dict.find("body") -
                                                     3] + '}')
                    try:
                        comment = Comment(comment, steem_instance=stm)
                        comment.refresh()
                        created = comment["created"]
                    except:
                        continue
                    if comment.is_pending():
                        continue
                    if comment["author"] != account["name"]:
                        continue

                    if comment["parent_author"] == "" and created > addTzInfo(
                            last_paid_post):
                        print("add post %s" % comment["authorperm"])
                        blog.append(comment["authorperm"])
                    elif comment["parent_author"] != "" and created > addTzInfo(
                            last_paid_comment):
                        print("add comment %s" % comment["authorperm"])
                        posts.append(comment["authorperm"])

                post_rshares = 0
                for authorperm in blog:
                posting_auth = True

        already_voted = False
        for v in c_comment.get_votes():
            if v["voter"] == rewarding_account:
                already_voted = True
        if already_voted:
            continue

        if c_comment.is_main_post():
            c = c_comment
        else:
            c = Comment(construct_authorperm(c_comment["parent_author"],
                                             c_comment["parent_permlink"]),
                        steem_instance=stm)
        if not (c.is_pending() and valid_age(c)):
            body = "The reward of this comment goes 100 %% to the author %s. This is done by setting the beneficiaries of this comment to 100 %%.\n\n" % (
                c["author"])
            comment_beneficiaries = [{"account": c["author"], "weight": 10000}]
            permlink = derive_permlink("rewarding %s" % c["author"],
                                       c_comment["permlink"])
            stm.post("rewarding %s" % c["author"],
                     body,
                     author=rewarding_account,
                     permlink=permlink,
                     reply_identifier=c_comment["authorperm"],
                     beneficiaries=comment_beneficiaries)
            time.sleep(3)

            authorperm = construct_authorperm(rewarding_account, permlink)
            comment_timestamp = datetime.utcnow()
Example #5
0
                maximum_vote_delay = acc_data["maximum_vote_delay"]
                rshares_divider = acc_data["rshares_divider"]
                if rshares_divider <= 0:
                    rshares_divider = 5
            else:
                minimum_vote_delay = 0
                maximum_vote_delay = 6.5 * 24 * 60
                rshares_divider = 5            
            
            best_performance = 0
            best_vote_delay_min = 0            
            performance = 0
            rshares = 0
            voter_rshares = 0

            if c.is_pending():
                for vote in c["active_votes"]:
                    if vote["voter"] == vote_log["voter"]:
                        rshares = int(vote["rshares"])
                for vote in c["active_votes"]:

                    voter_rshares = int(vote["rshares"])
                    
                    curation_SBD = curation_rewards_SBD["active_votes"][vote["voter"]]
                    if voter_rshares > 0 and vote["voter"] == vote_log["voter"]:
                        vote_SBD = stm.rshares_to_sbd(voter_rshares)
                        performance = (float(curation_SBD) / vote_SBD * 100)   
                    if voter_rshares > 0 and voter_rshares > rshares / rshares_divider:
                        vote_SBD = stm.rshares_to_sbd(voter_rshares)
                        p = float(curation_rewards_SBD["active_votes"][vote["voter"]]) / vote_SBD * 100
                        if p > best_performance: