Fixed zeroname_updater.py crashing underwindows with UTF8

For some reason windows doesn't like parsing namecoin domains with "weird" characters, so adding a try to catch exception stops a strange block crashing the script - instead it ignores and moves on.
We just have to hope there doesn't happen to be a namecoin domain in a block with weird characters.
This commit is contained in:
Idealcoder 2015-06-17 21:14:41 +01:00
parent 6155899893
commit 0fa87523fd
1 changed files with 8 additions and 5 deletions

View File

@ -59,11 +59,14 @@ def processBlock(block_id):
print "Checking %s tx" % len(block["tx"]) print "Checking %s tx" % len(block["tx"])
updated = 0 updated = 0
for tx in block["tx"]: for tx in block["tx"]:
transaction = rpc.getrawtransaction(tx, 1) try:
for vout in transaction.get("vout",[]): transaction = rpc.getrawtransaction(tx, 1)
if "scriptPubKey" in vout and "nameOp" in vout["scriptPubKey"] and "name" in vout["scriptPubKey"]["nameOp"]: for vout in transaction.get("vout",[]):
name_op = vout["scriptPubKey"]["nameOp"] if "scriptPubKey" in vout and "nameOp" in vout["scriptPubKey"] and "name" in vout["scriptPubKey"]["nameOp"]:
updated += processNameOp(name_op["name"].replace("d/", ""), name_op["value"]) name_op = vout["scriptPubKey"]["nameOp"]
updated += processNameOp(name_op["name"].replace("d/", ""), name_op["value"])
except Exception, err:
print "Error processing tx #%s %s" % (tx, err)
print "Done in %.3fs (updated %s)." % (time.time()-s, updated) print "Done in %.3fs (updated %s)." % (time.time()-s, updated)
if updated: if updated:
publish() publish()