def refresh_index(first_block, last_block):
    """
    """

    start = datetime.datetime.now()

    print "block count: %i" % bitcoind.getblockcount()

    nameop_sequence = []

    for block_number in range(first_block, last_block + 1):
        print block_number
        block_nameops = get_nameops_in_block(bitcoind, block_number)
        nameop_sequence.append((block_number, block_nameops))

    print nameop_sequence

    print "%s seconds" % (datetime.datetime.now() - start).seconds

    db = NameDb()
    merkle_snapshot = build_nameset(db, nameop_sequence)
    db.save_names('namespace.txt')

    print "merkle snapshot: %s\n" % merkle_snapshot
    pprint(db.name_records)

    fout = open('lastblock.txt', 'w')  # to overwrite
    fout.write(str(last_block))
    fout.close()
Beispiel #2
0
def refresh_index(first_block, last_block):
    """
    """

    start = datetime.datetime.now()

    print "block count: %i" % bitcoind.getblockcount()

    nameop_sequence = []

    for block_number in range(first_block, last_block + 1):
        print block_number
        block_nameops = get_nameops_in_block(bitcoind, block_number)
        nameop_sequence.append((block_number, block_nameops))

    print nameop_sequence

    print "%s seconds" % (datetime.datetime.now() - start).seconds

    db = NameDb()
    merkle_snapshot = build_nameset(db, nameop_sequence)
    db.save_names('namespace.txt')

    print "merkle snapshot: %s\n" % merkle_snapshot
    pprint(db.name_records)

    fout = open('lastblock.txt', 'w')  # to overwrite
    fout.write(str(last_block))
    fout.close()
Beispiel #3
0
def refresh_index(first_block, last_block, initial_index=False):
    """
    """

    from twisted.python import log as twisted_log

    working_dir = get_working_dir()

    namespace_file = os.path.join(working_dir,
                                  config.BLOCKSTORED_NAMESPACE_FILE)
    snapshots_file = os.path.join(working_dir,
                                  config.BLOCKSTORED_SNAPSHOTS_FILE)
    lastblock_file = os.path.join(working_dir,
                                  config.BLOCKSTORED_LASTBLOCK_FILE)

    start = datetime.datetime.now()

    nameop_sequence = []

    if initial_index:
        log.info('Creating initial index ...')

    for block_number in range(first_block, last_block + 1):
        if initial_index:
            log.info('Processing block %s', block_number)
        else:
            twisted_log.msg('Processing block', block_number)

        block_nameops = get_nameops_in_block(bitcoind, block_number)

        if initial_index:
            log.info('block_nameops %s', block_nameops)
        else:
            twisted_log.msg('block_nameops', block_nameops)

        nameop_sequence.append((block_number, block_nameops))

    # log.info(nameop_sequence)

    time_taken = "%s seconds" % (datetime.datetime.now() - start).seconds
    # log.info(time_taken)

    db = get_namedb()
    merkle_snapshot = build_nameset(db, nameop_sequence)
    db.save_names(namespace_file)
    db.save_snapshots(snapshots_file)

    merkle_snapshot = "merkle snapshot: %s\n" % merkle_snapshot
    # log.info(merkle_snapshot)
    # log.info(db.name_records)

    fout = open(lastblock_file, 'w')  # to overwrite
    fout.write(str(last_block))
    fout.close()
Beispiel #4
0
def refresh_index(first_block, last_block, initial_index=False):
    """
    """

    from twisted.python import log as twisted_log

    working_dir = get_working_dir()

    namespace_file = os.path.join(
        working_dir, config.BLOCKSTORED_NAMESPACE_FILE)
    snapshots_file = os.path.join(
        working_dir, config.BLOCKSTORED_SNAPSHOTS_FILE)
    lastblock_file = os.path.join(
        working_dir, config.BLOCKSTORED_LASTBLOCK_FILE)

    start = datetime.datetime.now()

    nameop_sequence = []

    if initial_index:
        log.info('Creating initial index ...')

    for block_number in range(first_block, last_block + 1):
        if initial_index:
            log.info('Processing block %s', block_number)
        else:
            twisted_log.msg('Processing block', block_number)

        block_nameops = get_nameops_in_block(bitcoind, block_number)

        if initial_index:
            log.info('block_nameops %s', block_nameops)
        else:
            twisted_log.msg('block_nameops', block_nameops)

        nameop_sequence.append((block_number, block_nameops))

    # log.info(nameop_sequence)

    time_taken = "%s seconds" % (datetime.datetime.now() - start).seconds
    # log.info(time_taken)

    db = get_namedb()
    merkle_snapshot = build_nameset(db, nameop_sequence)
    db.save_names(namespace_file)
    db.save_snapshots(snapshots_file)

    merkle_snapshot = "merkle snapshot: %s\n" % merkle_snapshot
    # log.info(merkle_snapshot)
    # log.info(db.name_records)

    fout = open(lastblock_file, 'w')  # to overwrite
    fout.write(str(last_block))
    fout.close()