def check_transfer_state():

    from registrar.config import SERVER_FLEET, IGNORE_USERNAMES

    servers = SERVER_FLEET

    counter = 0

    for entry in registrar_state.find(timeout=False):

        counter += 1
        #print counter

        nmc_entry = nmc_state.find_one({"username": entry['username']})

        if nmc_entry is None:
            continue

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

        if nmc_entry['nmc_address'] != entry['nmc_address']:

            server_counter = 0

            while(server_counter != len(servers)):

                server = servers[server_counter]

                #print server

                namecoind = NamecoindClient(server)

                try:
                    resp = namecoind.validateaddress(nmc_entry['nmc_address'])
                except Exception as e:
                    print e
                    print server
                    server_counter += 1
                    sleep(3)
                    continue

                if 'ismine' in resp and resp['ismine'] is True:
                    entry['needsTransfer'] = True
                    entry['server'] = server
                    #print entry
                    registrar_state.save(entry)
                    break

                server_counter += 1

                if server_counter == 8:
                    print entry['username']
Example #2
0
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