Exemple #1
0
 def stream(self, opNames, *args, **kwargs):
     warnings.warn(
         "The stream() call has been moved to `steem.blockchain.Blockchain.stream()`",
         DeprecationWarning)
     from piston.blockchain import Blockchain
     return Blockchain(mode=kwargs.get("mode", "irreversible")).stream(
         opNames, *args, **kwargs)
Exemple #2
0
 def list_accounts(self, start=None, step=1000, limit=None, **kwargs):
     warnings.warn(
         "The list_accounts() call has been moved to `steem.blockchain.Blockchain.get_all_accounts()`",
         DeprecationWarning)
     from piston.blockchain import Blockchain
     return Blockchain(
         mode=kwargs.get("mode", "irreversible")).get_all_accounts(
             start=start, steps=step, **kwargs)
Exemple #3
0
def get_block(steem, blockchain_name):
    last_block = redis.get('%s_last_block' % blockchain_name)

    if last_block is None:
        # Fitst app fetch
        last_block = Blockchain(steem).get_current_block_num()
        print(last_block, settings.LOCALE)

    return int(last_block)
Exemple #4
0
    def handle(self, *args, **options):
        settings.LOCALE = {'golos': 'ru', 'steemit': 'en'}[options['bc']]

        updater = BaseUpdater()
        steem = Steem(updater.blockchain.wss)

        last_block = options['block_num'] or get_block(steem, options['bc'])

        logger.info('Parse from %s block' % last_block)

        types = {
            'vote': updater.vote,
            'comment': updater.comment,
        }

        for op in Blockchain(steem,
                             mode="irreversible").stream(['vote', 'comment'],
                                                         start=last_block):
            to_do = types.get(op['type'])

            try:
                # TODO запилить асинихронность
                # pool.apply_async(to_do, [op])

                to_do(op)
            except InterfaceError:
                # При 2х одновременно запущенных блокчейнах
                # TODO Сделать одним прощессом все блокчейны
                db.connection.close()
                to_do(op)
            except KeyboardInterrupt:
                break
            except:
                logger.exception('Handle op err: %s' % pprint.pformat(op))

            block_num = int(op['block_num'])

            if last_block < block_num:
                last_block = block_num
                redis.set('%s_last_block' % options['bc'], last_block)
Exemple #5
0
from piston.steem import Steem
from piston.blockchain import Blockchain

chain = Blockchain()

blacklist = [""]   

trusted_voters = [""]   

pk = ["postingkeyhere"] 

account = ["deutschbot"]

threshold = 1 

steem = Steem(keys=pk[0])) 

for operation in chain.ops(
                           filter_by=["vote"]
                          ):

    op = operation["op"]

    if op[0] == "vote":

        comment_voter = op[1]["voter"]

        if comment_voter in trusted_voters:

            comment_link = op[1]["permlink"]
            comment_author = op[1]["author"]
Exemple #6
0
 def block_stream(self, start=None, stop=None, mode="irreversible"):
     warnings.warn(
         "The block_stream() call has been moved to `steem.blockchain.Blockchain.blocks()`",
         DeprecationWarning)
     from piston.blockchain import Blockchain
     return Blockchain(mode=mode).blocks(start, stop)
Exemple #7
0
votewith = 'accountname'
wif = '5...'
node = 'ws://steemd.pevo.science:8090'

follow = {
    'curator1': 0.1,  # follow with 10% of curator's weight
    'curator2': 10  # follow with 10% fixed
}

clones = {'curator1': ['sockpuppet1', 'sockpuppet2']}

except_authors = ['spammer', 'plagiarizer']

client = Steem(node=node, wif=wif)
blockchain = Blockchain()
rpc = SteemNodeRPC(node)
conn = sqlite3.connect('bot.db')
c = conn.cursor()


def main(lastblock):
    thisblock = blockchain.get_current_block_num()
    if lastblock == thisblock:
        return thisblock

    for op in blockchain.ops(lastblock + 1, thisblock):
        type = op['op'][0]
        op = op['op'][1]
        op['type'] = type
        if op['type'] == 'vote':