Made the following changes:

1) Removed the wait period for user to fill out profile (name_new is sent straight away)
2) When a name is activated, the latest value of the key is sent the blockchain (incase the user updated profile in meanwhile)
3) Better support for tracking no. of confirmations on name_new
This commit is contained in:
Muneeb Ali
2014-12-01 19:13:04 -05:00
parent f266a73560
commit 507c03f9ed
4 changed files with 41 additions and 29 deletions

View File

@@ -36,6 +36,10 @@ from blockdata.register import slice_profile
def refresh_value(entry):
username = entry['username']
user = users.find_one({"username":username})
if user is None:
return None
profile = user['profile']
keys, values = slice_profile(username,profile)
@@ -45,6 +49,14 @@ def refresh_value(entry):
return values[counter]
counter += 1
#-----------------------------------
def clean_wallet():
for entry in register_queue.find():
if entry['tx_sent'] is True:
entry['tx_sent'] = False
register_queue.save(entry)
#-----------------------------------
def do_name_firstupdate():
@@ -84,17 +96,18 @@ def do_name_firstupdate():
if 'wait_till_block' not in entry:
if 'txid' in entry:
reply = namecoind.gettransaction(entry['txid'])
else:
log.debug("remove longhex from code")
reply = namecoind.gettransaction(entry['longhex'])
reply = namecoind.gettransaction(entry['txid'])
if 'code' in reply:
register_queue.remove(entry)
continue
if reply['confirmations'] > 1:
log.debug('Got confirmations on name_firstupdate: %s' % entry['key'])
log.debug('Got confirmations on name_new: %s' % entry['key'])
entry['wait_till_block'] = namecoind.blocks() + (12 - reply['confirmations'])
register_queue.save(entry)
else:
log.debug('No confirmations on name_firstupdate: %s' % entry['key'])
log.debug('No confirmations on name_new: %s' % entry['key'])
continue
if entry['wait_till_block'] <= blocks:
@@ -107,22 +120,19 @@ def do_name_firstupdate():
ignore_servers.append(server)
continue
update_value = None
if 'username' in entry:
log.debug('refreshing value')
update_value = get_string(refresh_value(entry))
else:
update_value = get_string(entry['value'])
if update_value is None:
update_value = get_string(entry['value'])
log.debug("Activating entry: '%s' to point to '%s'" % (key, update_value))
if 'txid' in entry:
output = namecoind.firstupdate(key,entry['rand'],update_value,entry['txid'])
else:
log.debug('remove longhex from code')
output = namecoind.firstupdate(key,entry['rand'],update_value,entry['longhex'])
output = namecoind.firstupdate(key,entry['rand'],update_value,entry['txid'])
log.debug(output)
entry['tx_sent'] = True
if 'message' in output and output['message'] == "this name is already active":
register_queue.remove(entry)
elif 'message' in output and output['message'] == "previous transaction is not in the wallet":
@@ -156,6 +166,7 @@ def do_name_firstupdate():
#-----------------------------------
if __name__ == '__main__':
#clean_wallet()
do_name_firstupdate()
exit(0)

View File

@@ -73,7 +73,7 @@ def do_name_transfer(username,live=False):
#-----------------------------------
if __name__ == '__main__':
live = True
live = False
username = "clone66"

View File

@@ -280,10 +280,10 @@ def get_pending_state():
#-----------------------------------
if __name__ == '__main__':
cleanup_db()
#check_transfer()
#update_users()
#register_users()
#cleanup_db()
check_transfer()
update_users()
register_users()
get_pending_state()
#get_pending_state()

View File

@@ -30,7 +30,7 @@ MAX_PENDING_TX = 50
#-----------------------------------
def pending_transactions():
reply = namecoind.namecoind.listtransactions("",10000)
reply = namecoind.listtransactions("",10000)
counter = 0
@@ -80,14 +80,15 @@ if __name__ == '__main__':
new_user = users.find_one({'username':username})
if new_user is not None:
print username + " in new DB"
profile = get_json(new_user['profile'])
try:
process_user(username,profile)
except Exception as e:
# print e
#tx_sent += 1
#print '-' * 5
#continue
print e
tx_sent += 1
print '-' * 5
continue
old_user = old_users.find_one({'username':username})
if old_user is not None: