Exemplo n.º 1
0
def initiate_process_blocks_process(
    block_process_event,
    blocks_downloaded_queue,
    add_addresses_queue,
    jobs_queue,
    completed_jobs_process_blocks,
    exceptions
):
    process_blocks_event = Event()
    process_blocks_event.name = "process_blocks"
    events.append(process_blocks_event)
    process_blocks_process = Process(
        name="process_blocks",
        target=process_blocks,
        args=(
            process_blocks_event,
            block_process_event,
            blocks_downloaded_queue,
            add_addresses_queue,
            jobs_queue,
            completed_jobs_process_blocks,
            exceptions
        )
    )
    processes.append(process_blocks_process)
    logging.info("[-] Initiating process: Process downloaded blocks")
    process_blocks_process.start()
Exemplo n.º 2
0
def initiate_add_blocks_process(
    block_process_event,
    add_blocks_queue,
    jobs_queue,
    completed_jobs_add_blocks,
    exceptions
):
    add_blocks_event = Event()
    add_blocks_event.name = "add_blocks_event"
    events.append(add_blocks_event)
    add_blocks_process = Process(
        name="add_blocks",
        target=add_blocks,
        args=(
            add_blocks_event,
            block_process_event,
            add_blocks_queue,
            jobs_queue,
            completed_jobs_add_blocks,
            exceptions
        )
    )
    processes.append(add_blocks_process)
    logging.info("[-] Initiating process: Add blocks")
    add_blocks_process.start()
Exemplo n.º 3
0
def initiate_block_download_all_process(
    block_hashes_queue,
    blocks_downloaded_queue,
    exceptions
):
    block_download_all_event = Event()
    block_download_all_event.name = "block_download_all"
    events.append(block_download_all_event)
    block_download_all_process = Process(
        name="download_all_blocks",
        target=download_all_blocks,
        args=(
            block_download_all_event,
            block_hashes_queue,
            blocks_downloaded_queue,
            exceptions
        )
    )
    processes.append(block_download_all_process)
    logging.info("[-] Initiating process: Block download all")
    block_download_all_process.start()
Exemplo n.º 4
0
def initiate_block_hashes_download_process(
    start_block,
    block_hashes_queue,
    exceptions
):
    block_hash_download_event = Event()
    block_hash_download_event.name = "block_hash_download"
    events.append(block_hash_download_event)
    block_hash_download_process = Process(
        name="get_all_block_id_hashes",
        target=get_all_block_id_hashes,
        args=(
            block_hash_download_event,
            block_hashes_queue,
            start_block,
            exceptions
        )
    )
    processes.append(block_hash_download_process)
    logging.info("[-] Initiating process: Block hashes download")
    block_hash_download_process.start()
Exemplo n.º 5
0
def start(host, port, tor=False):
    start_time = time.time()
    main_event = Event()
    main_event.name = "main"
    events.append(main_event)
    main_event.set()
    while main_event.is_set():
        try:
            sync_event = Event()
            sync_event.name = "sync"
            events.append(sync_event)
            db_default_client = connect_default_db()
            db_clients.append(db_default_client)
            if tor:
                logging.info("[-] Tor connection is requested")
                logging.info("[-] SOCKS5 proxy listener will be used")
            logging.info("[-] Network connection to bitcoin node {}:{}".format(host, port))
            if DELETE_FROM_BLOCK_HEIGHT:
                resolve_blocks_from_height(DELETE_FROM_BLOCK_HEIGHT)
                quit(start_time)
            else:
                main(sync_event)
        except ServerSelectionTimeoutError:
            logging.critical("[!] Unable to connect to database")
            restart()
            logging.warning("[!] Database connection: re-attempting in 30 seconds")
            try:
                time.sleep(30)
            except KeyboardInterrupt:
                logging.info("[-] CTRL-C detected. Exiting gracefully")
                print("Exiting. Please wait for clean up process to complete")
                quit(start_time)
        except TorNotAvailable:
            logging.critical("[!] Tor is not available")
            restart()
            logging.warning("[!] Tor connection: re-attempting in 30 seconds")
            try:
                time.sleep(30)
            except KeyboardInterrupt:
                logging.info("[-] CTRL-C detected. Exiting gracefully")
                print("Exiting. Please wait for clean up process to complete")
                quit(start_time)
        except (ProcessBlockFailed, DatabaseQueryFailed) as process_block_error:
            logging.critical("[!] {}".format(process_block_error))
            logging.critical("[!] Invalid block")
            restart()
            logging.critical("[!] Halting sync for 60 seconds")
            try:
                time.sleep(60)
            except KeyboardInterrupt:
                logging.info("[-] CTRL-C detected. Exiting gracefully")
                print("Exiting. Please wait for clean up process to complete")
                quit(start_time)
        except (RuntimeError, BrokenPipeError, OSError, Exception) as network_error:
            logging.warning("[!] {}".format(network_error))
            logging.critical("[!] Unable to connect to bitcoin node")
            restart()
            logging.warning("[!] Bitcoin node connection: re-attempting in 30 seconds")
            try:
                time.sleep(30)
            except KeyboardInterrupt:
                logging.info("[-] CTRL-C detected. Exiting gracefully")
                print("Exiting. Please wait for clean up process to complete")
                quit(start_time)
        except KeyboardInterrupt:
            logging.info("[-] CTRL-C detected. Exiting gracefully")
            print("Exiting. Please wait for clean up process to complete")
            quit(start_time)