From 0fa87523fd7b95d9b9991d0d36fd7f7615409aa2 Mon Sep 17 00:00:00 2001 From: Idealcoder Date: Wed, 17 Jun 2015 21:14:41 +0100 Subject: [PATCH] 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. --- plugins/Zeroname/updater/zeroname_updater.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/Zeroname/updater/zeroname_updater.py b/plugins/Zeroname/updater/zeroname_updater.py index 1434a1d5..26191a87 100644 --- a/plugins/Zeroname/updater/zeroname_updater.py +++ b/plugins/Zeroname/updater/zeroname_updater.py @@ -59,11 +59,14 @@ def processBlock(block_id): print "Checking %s tx" % len(block["tx"]) updated = 0 for tx in block["tx"]: - transaction = rpc.getrawtransaction(tx, 1) - for vout in transaction.get("vout",[]): - if "scriptPubKey" in vout and "nameOp" in vout["scriptPubKey"] and "name" in vout["scriptPubKey"]["nameOp"]: - name_op = vout["scriptPubKey"]["nameOp"] - updated += processNameOp(name_op["name"].replace("d/", ""), name_op["value"]) + try: + transaction = rpc.getrawtransaction(tx, 1) + for vout in transaction.get("vout",[]): + if "scriptPubKey" in vout and "nameOp" in vout["scriptPubKey"] and "name" in vout["scriptPubKey"]["nameOp"]: + 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) if updated: publish()