Ejemplo n.º 1
0
def main():
    """ Main method which runs the tool from the given block numbers """
    start = time.time()
    print ("starting time: " + str(start))
    # Create MySQL Database and connect
    Database_manager.initialize_db()
    # Create MySQL Tables
    Database_manager.create_table_exchanges()
    Database_manager.create_table_shapeshift_addresses_btc()

    # Delete all data from DB
    Database_manager.delete_all_data()

    # Find Exchanges
    print ("Searching for Exchanges...")
    currencies_list = ["BTC", "ETH"]
    # February data
    current_block_number_dict = {"BTC": 511557, "ETH": 5180422}
    exchange_finder = Exchange_finder(currencies_list, current_block_number_dict=current_block_number_dict)
    exchange_finder.find_exchanges()
    print("Duration: " + str(time.time() - start))
Ejemplo n.º 2
0
def main():
    # Create MySQL Database and connect
    Database_manager.initialize_db()
    # Create MySQL Tables
    Database_manager.create_table_shapeshift()
    Database_manager.create_table_cmc()
    Database_manager.create_table_exchanges()

    previous_exchanges = []

    # Dalete all data from DB
    Database_manager.delete_all_data()

    # Update Coinmarketcap data
    last_time_updated_cmc = update_cmc(None)
    # Update Shapeshift
    last_time_updated_ss = update_ssf(None)

    while True:
        result = Shapeshift.get_last_transactions(previous_exchanges)
        if result:
            new_exchanges = result["new_exchanges"]
            # After every loop: Wait the half of the duration of retrieved 50 Txs
            duration_to_wait = result["duration"].total_seconds()/2
            if new_exchanges:
                print ("Starting loop: " + str(datetime.datetime.now()))
                start_time = time.time()

                # Update Coinmarketcap data
                last_time_updated_cmc = update_cmc(last_time_updated_cmc)
                # Update Shapeshift
                last_time_updated_ss = update_ssf(last_time_updated_ss)

                previous_exchanges = new_exchanges

                print ("Search for Ethereum Txs...")
                left_transactions_eth = Ether.get_ethereum_transaction(new_exchanges)
                if left_transactions_eth:
                    Ether.get_ethereum_transaction_infura(left_transactions_eth)
                print ("Search for Litecoin Txs...")
                left_transactions_ltc = Litecoin.get_litecoin_transaction(new_exchanges)
                if left_transactions_ltc:
                    time.sleep(50)
                    Litecoin.get_litecoin_transaction(left_transactions_ltc)
                print ("Search for Bitcoin Txs...")
                left_transactions_btc = Bitcoin.get_bitcoin_transaction(new_exchanges)
                if left_transactions_btc:
                    #time.sleep(30)
                    Bitcoin.get_bitcoin_transaction(left_transactions_btc)
                print ("Finished loop: " + str(datetime.datetime.now()))
                elapsed_time = time.time() - start_time
                if elapsed_time < duration_to_wait:
                    print ("Done! Wait " + str(duration_to_wait - elapsed_time) + " seconds")
                    time.sleep(duration_to_wait - elapsed_time)

            else:
                print ("No Transactions. Wait " + str(duration_to_wait) + " seconds")
                time.sleep(duration_to_wait)
        else:
            print ("Retrieving Transactions from Shapeshift didn't work")
            time.sleep(180)