def process_profile(username, profile, new_address=None): if username in problem_users: return try: process_user(username, profile, load_servers[current_server], new_address) except Exception as e: print e
def compare_states(): counter_not_registered = 0 # check if registrar has pending registrations for entry in registrar_state.find(): check_entry = nmc_state.find_one({"username": entry['username']}) if check_entry is None: # special case: remove the junk bitcoin addresses if len(entry['username']) == 34: print entry['username'] #registrar_state.remove(entry) counter_not_registered += 1 print "Not registered on nmc: %s" % counter_not_registered # check if registrar's view matches nmc counter_profile_data_mismatch = 0 counter_send_profile_update = 0 for entry in registrar_state.find(timeout=False): nmc_entry = nmc_state.find_one({"username": entry['username']}) if nmc_entry is None: continue if entry['profile_hash'] != nmc_entry['profile_hash']: #print entry['username'] counter_profile_data_mismatch += 1 if 'needsTransfer' in entry and entry['needsTransfer'] is True: counter_send_profile_update += 1 if entry['username'] in IGNORE_USERNAMES: continue else: user = users.find_one({"username": entry['username']}) print user['username'] try: process_user(user['username'], user['profile'], new_address=user['namecoin_address']) except Exception as e: print e print "Profile hash mismatch: %s" % counter_profile_data_mismatch print "Registrar profiles to update: %s" % counter_send_profile_update
def update_migration_users(): for user in migration_users.find(): resp = namecoind.name_show('u/' + user['username']) if 'address' in resp: nmc_address = resp['address'] if nmc_address != user['nmc_address']: try: process_user(user['username'], user['profile'], new_address=user['nmc_address']) except Exception as e: print e
def process_api_registraions(LIVE=False): base_url = 'http://resolver.onename.com/v1/users/' new_users = api_db['passcard'] for entry in new_users.find(): username = entry['passname'] transfer_address = entry['transfer_address'] profile = json.loads(entry['payload']) resp = requests.get(base_url + username) data = resp.json() if 'error' in data: # if not registered on the blockchain print "register: " + username if LIVE: process_user(username, profile) else: # if registered and not in our DBs check_user_db1 = users.find_one({"username": username}) check_user_db2 = old_users.find_one({"username": username}) if check_user_db1 is None and check_user_db2 is None: profile = namecoind.name_show('u/' + username) check_address = profile['address'] if check_address == transfer_address: print "already transferred" if LIVE: new_users.remove(entry) else: print "transfer: " + username print transfer_address if LIVE: transfer_name(username, transfer_address, live=True)
def reprocess_user(username): user = users.find_one({"username": username}) process_user(user['username'], user['profile'], new_address=user['namecoin_address'])
def make_alias(alias, target): value = {} value['next'] = 'u/' + target process_user(alias, value)
def process_manually_old(username): user = old_users.find_one({'username': username}) process_user(user['username'], json.loads(user['profile']))
def process_manually(username): user = users.find_one({'username': username}) process_user(user['username'], user['profile'])
def process_manually_alias(username, alias): user = users.find_one({'username': username}) process_user(alias, user['profile'])