Beispiel #1
0
def create_comparative_analysis_files(versions, count_p2sh, non_std_only):
    # The following analysis reads/writes from/to large data files. Some of the steps can be ignored if those files have
    # already been created (if more updated data is not requited). Otherwise lot of time will be put in re-parsing large
    # files.

    # Set version and chainstate dir name
    str_version = "-".join([str(v) for v in versions])

    fins = dict()
    for v in versions:
        # When using snapshots of the chainstate, we store it as 'chainstate/version
        chainstate = 'chainstate/' + str(v)

        # When not using a snapshot, we directly use the chainstate under btc_core_dir
        # chainstate = 'chainstate'

        # Check if the directory for data exists, create it otherwise.
        if not path.isdir(CFG.data_path + str(v)):
            mkdir(CFG.data_path + str(v))

        # Set the name of the output data files
        f_utxos, f_parsed_txs, f_parsed_utxos, f_dust = set_out_names(
            v, count_p2sh, non_std_only)

        fins[str(v)] = [f_parsed_txs, f_parsed_utxos]
        # Parse all the data in the chainstate.
        parse_ldb(f_utxos, fin_name=chainstate, version=v)

        # Parses transactions and utxos from the dumped data.
        transaction_dump(f_utxos, f_parsed_txs, version=v)
        utxo_dump(f_utxos, f_parsed_utxos, version=v)

    # Check if the directory for figures exist, create it otherwise.
    if not path.isdir(CFG.figs_path + str_version):
        mkdir(CFG.figs_path + str_version)
def run_experiment(coin, chainstate, count_p2sh, non_std_only):
    """
    Runs the whole experiment. You may comment the parts of it you are not interested in to save time.

    :param coin: Coin to be used in the experiment (bitcoin, litecoin, bitcoin cash, ...)
    :type coin: str
    :param chainstate: Chainstate path.
    :type chainstate: str
    :param count_p2sh: Whether P2SH outputs are included in the experiment or not.
    :type count_p2sh: bool
    :param non_std_only: Whether the experiment is performed only counting non standard outputs.
    :type non_std_only:bool
    :return:
    """

    # The following analysis reads/writes from/to large data files. Some of the steps can be ignored if those files have
    # already been created (if more updated data is not requited). Otherwise lot of time will be put in re-parsing large
    # files.

    # Set the name of the output data files
    f_utxos, f_parsed_txs, f_parsed_utxos, f_dust = set_out_names(
        count_p2sh, non_std_only)

    # Parse all the data in the chainstate.
    print "Parsing the chainstate."
    parse_ldb(f_utxos, fin_name=chainstate)

    # Parses transactions and utxos from the dumped data.
    print "Adding meta-data for transactions and UTXOs."
    transaction_dump(f_utxos, f_parsed_txs)
    utxo_dump(f_utxos,
              f_parsed_utxos,
              coin,
              count_p2sh=count_p2sh,
              non_std_only=non_std_only)

    # Print basic stats from data
    print "Running overview analysis."
    overview_from_file(f_parsed_txs, f_parsed_utxos)

    # Generate plots from tx data (from f_parsed_txs)
    print "Running transaction based analysis."
    tx_based_analysis(f_parsed_txs)

    # Generate plots from utxo data (from f_parsed_utxos)
    print "Running UTXO based analysis."
    utxo_based_analysis(f_parsed_utxos)

    # # Aggregates dust and generates plots.
    print "Running dust analysis."
    dust_analysis(f_parsed_utxos, f_dust)
    dust_analysis_all_fees(f_parsed_utxos)

    # Generate plots with filters
    print "Running analysis with filters."
    utxo_based_analysis_with_filters(f_parsed_utxos)
    tx_based_analysis_with_filters(f_parsed_txs)
Beispiel #3
0
    # When using snapshots of the chainstate, we store it as 'chainstate/version
    chainstate = 'chainstate/' + str(version)

    # Check if the directory for data exists, create it otherwise.
    if not path.isdir(CFG.data_path + str(version)):
        mkdir(CFG.data_path + str(version))

    # Set the name of the output data files
    f_utxos = str(version) + "/utxos.json"
    f_parsed_utxos = str(version) + "/parsed_utxos.json"
    f_parsed_txs = str(version) + "/parsed_txs.json"
    f_dust = str(version) + "/dust.json"
    non_std_utxos = str(version) + "/parsed_non_std_utxos.json"

    # Parse all the data in the chainstate.
    parse_ldb(f_utxos, fin_name=chainstate, version=version)

    # Parses transactions and utxos from the dumped data.
    transaction_dump(f_utxos, f_parsed_txs, version=version)
    utxo_dump(f_utxos, f_parsed_utxos, version=version)

# Check if the directory for figures exist, create it otherwise.
if not path.isdir(CFG.figs_path + str(version)):
    mkdir(CFG.figs_path + str(version))

# Generate plots from tx and utxo data

plots_from_file(["total_len"] * 2,
                y=["tx"] * 2,
                xlabel="Total length (bytes)",
                log_axis="x",
def run_experiment(version, chainstate, count_p2sh, non_std_only):
    """
    Runs the whole experiment. You may comment the parts of it you are not interested in to save time.

     :param version: Bitcoin core version, used to decide the folder in which to store the data.
    :type version: float
    :param chainstate: Chainstate path.
    :type chainstate: str
    :param count_p2sh: Whether P2SH outputs are included in the experiment or not.
    :type count_p2sh: bool
    :param non_std_only: Whether the experiment is performed only counting non standard outputs.
    :type non_std_only:bool
    :return:
    """

    # The following analysis reads/writes from/to large data files. Some of the steps can be ignored if those files have
    # already been created (if more updated data is not requited). Otherwise lot of time will be put in re-parsing large
    # files.

    # Check if the directories for both data and figures exist, create them otherwise.
    if not path.isdir(CFG.data_path + str(version)) and not path.isdir(CFG.figs_path + str(version)):
        mkdir(CFG.data_path + str(version))
        mkdir(CFG.figs_path + str(version))

    # Set the name of the output data files
    f_utxos, f_parsed_txs, f_parsed_utxos, f_dust = set_out_names(version, count_p2sh, non_std_only)

    # Parse all the data in the chainstate.
    print "Parsing the chainstate."
    parse_ldb(f_utxos, fin_name=chainstate, version=version)

    # Parses transactions and utxos from the dumped data.
    print "Adding meta-data for transactions and UTXOs."
    transaction_dump(f_utxos, f_parsed_txs, version=version)
    utxo_dump(f_utxos, f_parsed_utxos, count_p2sh=count_p2sh, non_std_only=non_std_only, version=version)

    # Print basic stats from data
    print "Running overview analysis."
    overview_from_file(f_parsed_txs, f_parsed_utxos, version)

    # Generate plots from tx data (from f_parsed_txs)
    print "Running transaction based analysis."
    tx_based_analysis(f_parsed_txs, version)

    # Generate plots from utxo data (from f_parsed_utxos)
    print "Running UTXO based analysis."
    utxo_based_analysis(f_parsed_utxos, version)

    # Aggregates dust and generates plots it.
    print "Running dust analysis."
    dust_analysis(f_parsed_utxos, f_dust, version)
    compare_dust(version)

    # Comparative data analysis (transactions and UTXOs)
    print "Running comparative data analysis."
    comparative_data_analysis(f_parsed_txs, f_parsed_utxos, version)

    # Generate plots with filters
    print "Running analysis with filters."
    utxo_based_analysis_with_filters(f_parsed_utxos, version)
    tx_based_analysis_with_filters(f_parsed_txs, version)
Beispiel #5
0
def printMostUpdateUTXOfile():
    f_utxos = "utxos"
    parse_ldb(f_utxos)
    fileStat = os.stat("data/utxos")
    return fileStat.st_size / 68