mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-01-12 22:43:42 +08:00
small updates for new coinrpc ver
This commit is contained in:
@@ -16,6 +16,8 @@ from commontools import utf8len, log
|
||||
|
||||
from time import sleep
|
||||
|
||||
from config import NAMECOIND_PORT, NAMECOIND_USER, NAMECOIND_PASSWD, NAMECOIND_WALLET_PASSPHRASE, NAMECOIND_USE_HTTPS, NAMECOIND_SERVER
|
||||
|
||||
#-----------------------------------
|
||||
from pymongo import MongoClient
|
||||
client = MongoClient()
|
||||
@@ -37,7 +39,7 @@ def do_name_firstupdate():
|
||||
|
||||
#entry is registered; but not activated
|
||||
if entry.get('activated') is not None and entry.get('activated') == False:
|
||||
|
||||
|
||||
key = entry['key']
|
||||
|
||||
#compare the current block with 'wait_till_block'
|
||||
@@ -50,17 +52,19 @@ def do_name_firstupdate():
|
||||
log.debug("Activating entry: '%s' to point to '%s'" % (key, update_value))
|
||||
|
||||
server = entry['server']
|
||||
|
||||
log.debug(server)
|
||||
|
||||
namecoind = NamecoindServer(server, NAMECOIND_PORT, NAMECOIND_USER, NAMECOIND_PASSWD, NAMECOIND_USE_HTTPS, NAMECOIND_WALLET_PASSPHRASE)
|
||||
|
||||
try:
|
||||
output = namecoind.firstupdate(key,entry['rand'],update_value,entry['longhex'])
|
||||
log.debug("tx: %s", output)
|
||||
except:
|
||||
continue
|
||||
output = namecoind.firstupdate(key,entry['rand'],update_value,entry['longhex'])
|
||||
log.debug(output)
|
||||
#except Exception as e:
|
||||
# log.debug(e)
|
||||
|
||||
if 'message' in output and output['message'] == "this name is already active":
|
||||
entry['activated'] = True
|
||||
elif 'message' in output and output['message'] == "previous transaction is not in the wallet":
|
||||
entry['activated'] = True
|
||||
elif 'code' in output:
|
||||
entry['activated'] = False
|
||||
log.debug("Not activated. Try again.")
|
||||
|
||||
@@ -44,10 +44,17 @@ def register_name(key,value,server=NAMECOIND_SERVER):
|
||||
|
||||
namecoind = NamecoindServer(server, NAMECOIND_PORT, NAMECOIND_USER, NAMECOIND_PASSWD, NAMECOIND_USE_HTTPS, NAMECOIND_WALLET_PASSPHRASE)
|
||||
|
||||
info = namecoind.name_new(key,json.dumps(value))
|
||||
try:
|
||||
info = namecoind.name_new(key,json.dumps(value))
|
||||
|
||||
reply['longhex'] = info[0]
|
||||
reply['rand'] = info[1]
|
||||
|
||||
except:
|
||||
log.debug(info)
|
||||
reply['message'] = info
|
||||
return reply
|
||||
|
||||
reply['longhex'] = info[0]
|
||||
reply['rand'] = info[1]
|
||||
reply['key'] = key
|
||||
reply['value'] = json.dumps(value)
|
||||
|
||||
@@ -59,6 +66,7 @@ def register_name(key,value,server=NAMECOIND_SERVER):
|
||||
reply['activated'] = False
|
||||
reply['server'] = server
|
||||
|
||||
|
||||
#save this data to Mongodb...
|
||||
register_queue.insert(reply)
|
||||
|
||||
@@ -92,7 +100,7 @@ def update_name(key,value):
|
||||
namecoind = NamecoindServer(server, NAMECOIND_PORT, NAMECOIND_USER, NAMECOIND_PASSWD, NAMECOIND_USE_HTTPS, NAMECOIND_WALLET_PASSPHRASE)
|
||||
|
||||
info = namecoind.name_update(key,json.dumps(value))
|
||||
|
||||
|
||||
if 'code' in info:
|
||||
reply = info
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user