def relayed_by_cacher(self):
        try:
            database_connector = address_reuse.db.Database(TEMP_DB_FILENAME)

            relayed_by_producer_identity = address_reuse.data_subscription.DataProducer.BLOCK_RELAYED_BY_CACHED_IN_DB
            relayed_by_announcer = address_reuse.data_subscription.BlockDataProductionAnnouncer(
                relayed_by_producer_identity, database_connector
            )

            api_reader = address_reuse.blockchain_reader.ThrottledBlockchainReader(database_connector)
            block_processor = address_reuse.block_processor.BlockProcessor(api_reader, database_connector)
            for i in range(0, 171):
                print("DEBUG: relayed_by_cacher @ height %d" % i)
                block_processor.cache_relayed_by_fields_for_block_only(i)
                print(("DEBUG: relayed_by_cacher @ height %d: Cached fields " "for this block." % i))
                relayed_by_announcer.increment_announced_block_available()
        except Exception as e:
            print(str(e))
    def relayed_by_cacher(self):
        try:
            database_connector = address_reuse.db.Database(TEMP_DB_FILENAME)

            relayed_by_producer_identity = address_reuse.data_subscription.DataProducer.BLOCK_RELAYED_BY_CACHED_IN_DB
            relayed_by_announcer = address_reuse.data_subscription.BlockDataProductionAnnouncer(
                relayed_by_producer_identity, database_connector)

            api_reader = address_reuse.blockchain_reader.ThrottledBlockchainReader(
                database_connector)
            block_processor = address_reuse.block_processor.BlockProcessor(
                api_reader, database_connector)
            for i in range(0, 171):
                print("DEBUG: relayed_by_cacher @ height %d" % i)
                block_processor.cache_relayed_by_fields_for_block_only(i)
                print(("DEBUG: relayed_by_cacher @ height %d: Cached fields "
                       "for this block." % i))
                relayed_by_announcer.increment_announced_block_available()
        except Exception as e:
            print(str(e))
Ejemplo n.º 3
0
num_blocks_remaining_to_process = current_blockchain_height - current_height_iterated

block_processor = address_reuse.block_processor.BlockProcessor(api_reader, db)

benchmarker = address_reuse.benchmark.block_reader_benchmark.Benchmark()

last_block_height_processed = None
try:
    while (current_height_iterated < current_blockchain_height):
        print(("DEBUG: update_relayed_by_cache.py: current block height of "
               "blockchain is %d, last block processed in db is %d, %d "
               "remaining blocks to process in this run.") %
              (current_blockchain_height, current_height_iterated,
               num_blocks_remaining_to_process))

        block_processor.cache_relayed_by_fields_for_block_only(
            current_height_iterated, benchmarker)

        print("Completed processing of block at height %d." %
              current_height_iterated)
        last_block_height_processed = current_height_iterated
        current_height_iterated = current_height_iterated + 1

        num_blocks_remaining_to_process = num_blocks_remaining_to_process - 1

        #Log successful processing of this block
        address_reuse.logger.log_status(
            'Cached relayed-by field for block %d.' %
            last_block_height_processed)

except Exception as e:
    traceback.print_exc()
num_blocks_remaining_to_process = current_blockchain_height - current_height_iterated

block_processor = address_reuse.block_processor.BlockProcessor(api_reader, db)

benchmarker = address_reuse.benchmark.block_reader_benchmark.Benchmark()

last_block_height_processed = None
try:
    while (current_height_iterated < current_blockchain_height):
        print(("DEBUG: update_relayed_by_cache.py: current block height of "
               "blockchain is %d, last block processed in db is %d, %d "
               "remaining blocks to process in this run.") % 
              (current_blockchain_height, current_height_iterated, 
               num_blocks_remaining_to_process))
        
        block_processor.cache_relayed_by_fields_for_block_only(
            current_height_iterated, benchmarker)
        
        print("Completed processing of block at height %d." % 
              current_height_iterated)
        last_block_height_processed = current_height_iterated
        current_height_iterated = current_height_iterated + 1
        
        num_blocks_remaining_to_process = num_blocks_remaining_to_process - 1
        
         #Log successful processing of this block
        address_reuse.logger.log_status('Cached relayed-by field for block %d.' % 
                                        last_block_height_processed)
        
except Exception as e:
    traceback.print_exc()
finally: