def insert_state_diff(username, profile, nmc_address):

    check_diff = state_diff.find_one({"username": username})

    if check_diff is None:
        new_entry = {}
        new_entry['username'] = username
        new_entry['btc_address'] = address_to_new_cryptocurrency(nmc_address, 0)
        new_entry['profile'] = profile
        new_entry['profile_hash'] = get_hash(profile)

        print "inserting in diff: %s" % username
        state_diff.insert(new_entry)
    else:
        print "already in diff: %s" % username
예제 #2
0
def insert_state_diff(username, profile, nmc_address):

    check_diff = state_diff.find_one({"username": username})

    if check_diff is None:
        new_entry = {}
        new_entry['username'] = username
        new_entry['btc_address'] = address_to_new_cryptocurrency(
            nmc_address, 0)
        new_entry['profile'] = profile
        new_entry['profile_hash'] = get_hash(profile)

        print "inserting in diff: %s" % username
        state_diff.insert(new_entry)
    else:
        print "already in diff: %s" % username
예제 #3
0
def calculate_old_users_bug():

    counter = 0
    for old_user in old_users.find():

        username = old_user['username']

        new_user = users.find_one({"username": username})

        if new_user is not None:

            btc_address = address_to_new_cryptocurrency(str(old_user['namecoin_address']), 0)
            btc_user = btc_state.find_one({"username": username})

            if btc_user is not None:
                if btc_address == btc_user['btc_address']:
                    print username
                    insert_btc_diff(username, new_user['profile'], str(new_user['namecoin_address']))
                    counter += 1
    print counter
예제 #4
0
def nmc_to_btc_address(nmc_address):

    return address_to_new_cryptocurrency(str(nmc_address), 0)
예제 #5
0
def create_migration_state():

    for entry in migration_users.find():

        check_entry = btc_state.find_one({"username": entry['username']})

        if check_entry is not None:
            print "%s already in btc_state" % entry['username']
            continue

        new_entry = {}
        new_entry['username'] = entry['username']
        new_entry['btc_address'] = entry['btc_address']
        new_entry['profile'] = entry['profile']
        new_entry['profile_hash'] = entry['profile_hash']

        btc_state.insert(new_entry)

    for entry in registrar_state.find():

        check_entry = btc_state.find_one({"username": entry['username']})

        if check_entry is not None:
            print "%s already in btc_state" % entry['username']
            continue

        if 'needsTransfer' in entry and entry['needsTransfer'] is True:

            new_entry = {}
            new_entry['username'] = entry['username']
            new_entry['btc_address'] = address_to_new_cryptocurrency(str(entry['nmc_address']), 0)
            new_entry['profile'] = entry['profile']
            new_entry['profile_hash'] = get_hash(entry['profile'])

            btc_state.insert(new_entry)

    for entry in nmc_state.find():

        check_entry = btc_state.find_one({"username": entry['username']})

        if check_entry is not None:
            print "%s already in btc_state" % entry['username']
            continue

        if 'reservedByOnename' in entry and entry['reservedByOnename'] is False:

            try:
                new_entry = {}
                new_entry['username'] = entry['username']
                resp = namecoind.name_show('u/' + entry['username'])

                new_entry['btc_address'] = address_to_new_cryptocurrency(str(entry['nmc_address']), 0)
                new_entry['profile'] = entry['profile']
                new_entry['profile_hash'] = entry['profile_hash']
            except:
                print "ERROR"
                print entry
            else:
                btc_state.insert(new_entry)
        else:
            print entry