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)
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)
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)
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)
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"]
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)