Пример #1
0
 def test_estimate_block_num(self):
     bts = self.bts
     b = Blockchain(dpay_instance=bts)
     last_block = b.get_current_block()
     num = last_block.identifier
     old_block = Block(num - 60, dpay_instance=bts)
     date = old_block.time()
     est_block_num = b.get_estimated_block_num(date, accurate=False)
     self.assertTrue((est_block_num - (old_block.identifier)) < 10)
     est_block_num = b.get_estimated_block_num(date, accurate=True)
     self.assertTrue((est_block_num - (old_block.identifier)) < 2)
     est_block_num = b.get_estimated_block_num(date,
                                               estimateForwards=True,
                                               accurate=True)
     self.assertTrue((est_block_num - (old_block.identifier)) < 2)
     est_block_num = b.get_estimated_block_num(date,
                                               estimateForwards=True,
                                               accurate=False)
Пример #2
0
            authorperm = construct_authorperm(vote_event["author"], vote_event["permlink"])
            # print(authorperm)
            try:
                process_vote_content(Comment(authorperm))
            except exceptions.ContentDoesNotExistsException:
                print("Could not find Comment: %s" % (authorperm))
            al = list()
            if not vote_event["voter"] in self.looked_up:
                al.append(vote_event["voter"])
                self.looked_up.add(vote_event["voter"])
            if not vote_event["author"] in self.looked_up:
                al.append(vote_event["author"])
                self.looked_up.add(vote_event["author"])
            if len(al) > 0:
                lookup_accounts(al)


if __name__ == "__main__":
    wtw = WatchingTheWatchers()
    tb = WatchingTheWatchersBot(wtw)
    blockchain = Blockchain()
    threading = True
    thread_num = 16
    cur_block = blockchain.get_current_block()
    stop = cur_block.identifier
    startdate = cur_block.time() - timedelta(days=1)
    start = blockchain.get_estimated_block_num(startdate, accurate=True)
    for vote in blockchain.stream(opNames=["vote"], start=start, stop=stop, threading=threading, thread_num=thread_num):
        tb.vote(vote)
    wtw.report()