Exemple #1
0
def register_users():

    counter = 0

    for new_user in registrations.find():

        user_id = new_user['user_id']
        user = users.find_one({"_id": user_id})

        if user is None:
            continue

        if not user['username_activated']:
            continue

        if check_banned(user['username']):
            continue

        print "checking: " + user['username']

        counter += 1

        check_queue = register_queue.find_one({"key": 'u/' + user['username']})

        if check_queue is not None:
            print "Already in queue"
            continue

        if 'dispatched' in new_user and new_user['dispatched'] is False:

            print "Dispatch: " + user['username']

            process_profile(user['username'],
                            user['profile'],
                            new_address=user['namecoin_address'])
            new_user['dispatched'] = True
            registrations.save(new_user)

        elif 'dispatched' in new_user and new_user['dispatched'] is True:

            if profile_on_blockchain(user["username"], user["profile"]):

                if nameTransferred(user, namecoind):
                    print "cleaning: " + user["username"]
                    registrations.remove(new_user)
                else:
                    transfer_name(user['username'],
                                  user['namecoin_address'],
                                  live=True)
            else:
                process_profile(user['username'],
                                user['profile'],
                                new_address=user['namecoin_address'])

        if counter % 5 == 0:
            load_balance()

    print counter
Exemple #2
0
def register_users():

    counter = 0

    for new_user in registrations.find():

        user_id = new_user['user_id']
        user = users.find_one({"_id": user_id})

        if user is None:
            continue

        if not user['username_activated']:
            continue

        if check_banned(user['username']):
            continue

        print "checking: " + user['username']

        counter += 1

        check_queue = register_queue.find_one({"key": 'u/' + user['username']})

        if check_queue is not None:
            print "Already in queue"
            continue

        if 'dispatched' in new_user and new_user['dispatched'] is False:

            print "Dispatch: " + user['username']

            process_profile(user['username'], user['profile'], new_address=user['namecoin_address'])
            new_user['dispatched'] = True
            registrations.save(new_user)

        elif 'dispatched' in new_user and new_user['dispatched'] is True:

            if profile_on_blockchain(user["username"], user["profile"]):

                if nameTransferred(user, namecoind):
                    print "cleaning: " + user["username"]
                    registrations.remove(new_user)
                else:
                    transfer_name(user['username'], user['namecoin_address'], live=True)
            else:
                process_profile(user['username'], user['profile'], new_address=user['namecoin_address'])

        if counter % 5 == 0:
            load_balance()

    print counter
Exemple #3
0
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)