def update_transfer_state(): counter = 0 for entry in registrar_state.find(): if 'needsTransfer' in entry and entry['needsTransfer'] is True: profile = entry['profile'] #print entry['username'] #print entry['server'] #print '-' * 5 #continue namecoind = NamecoindClient() try: resp = namecoind.name_show('u/' + entry['username']) except Exception as e: print e continue current_nmc_address = resp['address'] if current_nmc_address == entry['nmc_address']: print entry['username'] entry['needsTransfer'] = False registrar_state.save(entry) counter += 1 print counter
def prepare_diff_2(btc_state_file, btc_state_diff_file): fin = open(btc_state_file, 'r') first_import = json.loads(fin.read()) fin.close() fin = open(btc_state_diff_file, 'r') diff_1 = json.loads(fin.read()) fin.close() btc_namespace = first_import + diff_1 counter = 0 user_found = False for user in users.find(): username = user['username'] user_found = False if len(username) == 34 or len(username) == 33: continue if 'stormtrooper' in username or 'clone' in username: continue for check_user in btc_namespace: if username == check_user['username']: user_found = True break if user_found is True: continue namecoind = NamecoindClient() try: resp = namecoind.name_show('u/' + username) except Exception as e: print username print e continue if 'code' in resp: pass #print "not registered: %s" % username #print username #insert_btc_diff(username, user['profile'], str(user['namecoin_address'])) #counter += 1 else: print username print counter
def calculate_diff(): ban_users = [] counter = 0 for check_user in old_users.find(): username = check_user["username"] check_new_user = users.find_one({"username": username}) check_btc = btc_state.find_one({"username": username}) check_btc_diff = btc_state_diff.find_one({"username": username}) if check_btc is None and check_btc_diff is None and check_new_user is None: if len(username) == 34 or len(username) == 33: continue if 'stormtrooper' in username or 'clone' in username: continue if username in ban_users: continue namecoind = NamecoindClient() try: resp = namecoind.name_show('u/' + username) except Exception as e: print username print e continue if 'code' in resp: print "not registered: %s" % username continue try: resp_value = resp['value'] if 'message' in resp_value: print "reserved: %s" % username continue except Exception as e: print e try: current_nmc_address = resp['address'] except Exception as e: print resp continue if current_nmc_address == check_user['namecoin_address']: print "transferred new user: %s" % username insert_btc_diff(username, check_user['profile'], str(check_user['namecoin_address'])) else: namecoind = get_namecoind('u/' + username) try: resp = namecoind.validateaddress(current_nmc_address) except Exception as e: print e continue if 'ismine' in resp and resp['ismine'] is True: profile = check_user['profile'] if type(profile) is not dict: profile = json.loads(profile) insert_btc_diff(username, profile, str(check_user['namecoin_address'])) else: print "problem: %s" % username print check_user['namecoin_address'] print '-' * 5 counter += 1 print counter