def run_sync(): print("[HIVE] Welcome to hivemind") # make sure db schema is up to date, perform checks DbState.initialize() # prefetch id->name memory map Accounts.load_ids() if DbState.is_initial_sync(): # resume initial sync Sync.initial() DbState.finish_initial_sync() else: # recover from fork Blocks.verify_head() # perform cleanup in case process did not exit cleanly CachedPost.recover_missing_posts() while True: # sync up to irreversible block Sync.from_steemd() # take care of payout backlog CachedPost.dirty_paidouts(Blocks.head_date()) CachedPost.flush(trx=True) # start listening Sync.listen()
def run(cls): """Initialize state; setup/recovery checks; sync and runloop.""" # ensure db schema up to date, check app status DbState.initialize() # prefetch id->name memory map Accounts.load_ids() if DbState.is_initial_sync(): # resume initial sync cls.initial() DbState.finish_initial_sync() else: # recover from fork Blocks.verify_head() # perform cleanup if process did not exit cleanly CachedPost.recover_missing_posts() # debug mode: no sync, just stream if Conf.get('disable_sync'): return cls.listen() while True: # sync up to irreversible block cls.from_steemd() # take care of payout backlog CachedPost.dirty_paidouts(Blocks.head_date()) CachedPost.flush(trx=True) # listen for new blocks cls.listen()
def run(self): """Initialize state; setup/recovery checks; sync and runloop.""" # ensure db schema up to date, check app status DbState.initialize() # prefetch id->name and id->rank memory maps Accounts.load_ids() Accounts.fetch_ranks() Community.recalc_pending_payouts() if DbState.is_initial_sync(): # resume initial sync self.initial() DbState.finish_initial_sync() else: # recover from fork Blocks.verify_head(self._steem) # perform cleanup if process did not exit cleanly CachedPost.recover_missing_posts(self._steem) #audit_cache_missing(self._db, self._steem) #audit_cache_deleted(self._db) self._update_chain_state() if self._conf.get('test_max_block'): # debug mode: partial sync return self.from_steemd() if self._conf.get('test_disable_sync'): # debug mode: no sync, just stream return self.listen() while True: # sync up to irreversible block self.from_steemd() # take care of payout backlog CachedPost.dirty_paidouts(Blocks.head_date()) CachedPost.flush(self._steem, trx=True) try: # listen for new blocks self.listen() except MicroForkException as e: # attempt to recover by restarting stream log.error("NOTIFYALERT microfork: %s", repr(e))
def run(): print("[HIVE] Welcome to hivemind") # make sure db schema is up to date, perform checks DbState.initialize() # prefetch id->name memory map Accounts.load_ids() if DbState.is_initial_sync(): print("[INIT] *** Initial fast sync ***") sync_from_checkpoints() sync_from_steemd() print("[INIT] *** Initial cache build ***") # todo: disable indexes during this process cache_missing_posts() FeedCache.rebuild() DbState.finish_initial_sync() else: # recover from fork Blocks.verify_head() # perform cleanup in case process did not exit cleanly cache_missing_posts() while True: # sync up to irreversible block sync_from_steemd() # take care of payout backlog CachedPost.dirty_paidouts(Blocks.head_date()) CachedPost.flush(trx=True) # start listening listen_steemd()