From 9ffe305089150cc8b236c801d6b5c15d4f98e764 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 30 Mar 2012 12:47:35 +0400 Subject: [PATCH] new spec and conversion --- modules/abe/__init__.py | 24 ++++++++++++------------ modules/abe/__init__.pyc | Bin 14150 -> 14183 bytes transports/native.py | 10 ++++++++++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/modules/abe/__init__.py b/modules/abe/__init__.py index dc7056a..445d1b2 100644 --- a/modules/abe/__init__.py +++ b/modules/abe/__init__.py @@ -205,13 +205,13 @@ class AbeStore(Datastore_class): break tx_hash = self.hashout_hex(tx_hash) txpoint = { - "nTime": int(nTime), + "timestamp": int(nTime), "height": int(height), - "is_in": int(is_in), - "blk_hash": self.hashout_hex(blk_hash), + "is_input": int(is_in), + "block_hash": self.hashout_hex(blk_hash), "tx_hash": tx_hash, "tx_id": int(tx_id), - "pos": int(pos), + "index": int(pos), "value": int(value), } @@ -220,7 +220,7 @@ class AbeStore(Datastore_class): # todo: sort them really... - txpoints = sorted(txpoints, key=operator.itemgetter("nTime")) + txpoints = sorted(txpoints, key=operator.itemgetter("timestamp")) # read memory pool rows = [] @@ -243,13 +243,13 @@ class AbeStore(Datastore_class): #print "mempool", tx_hash txpoint = { - "nTime": 0, + "timestamp": 0, "height": 0, - "is_in": int(is_in), - "blk_hash": 'mempool', + "is_input": int(is_in), + "block_hash": 'mempool', "tx_hash": tx_hash, "tx_id": int(tx_id), - "pos": int(pos), + "index": int(pos), "value": int(value), } txpoints.append(txpoint) @@ -274,7 +274,7 @@ class AbeStore(Datastore_class): txpoint['outputs'] = txoutputs # for all unspent inputs, I want their scriptpubkey. (actually I could deduce it from the address) - if not txpoint['is_in']: + if not txpoint['is_input']: # detect if already redeemed... for row in outrows: if row[6] == dbhash: break @@ -284,7 +284,7 @@ class AbeStore(Datastore_class): # pos, script, value, o_hash, o_id, o_pos, binaddr = row # if not redeemed, we add the script if row: - if not row[4]: txpoint['raw_scriptPubKey'] = row[1] + if not row[4]: txpoint['raw_output_script'] = row[1] # cache result if not address_has_mempool: @@ -300,7 +300,7 @@ class AbeStore(Datastore_class): status = None else: lastpoint = tx_points[-1] - status = lastpoint['blk_hash'] + status = lastpoint['block_hash'] # this is a temporary hack; move it up once old clients have disappeared if status == 'mempool': # and session['version'] != "old": status = status + ':%d'% len(tx_points) diff --git a/modules/abe/__init__.pyc b/modules/abe/__init__.pyc index 344ae06e153c362d48681c214d59883a71689c16..7f7341f035c5cc2bd22deda285bb3e36a88d3a26 100644 GIT binary patch delta 773 zcmYk4&ubGw6vs0uZfr$}hbY)WF`;y+X|ZjLwH0#_3KbCsK@sVa&2HUon%#AGQj63Q zHK;dRMxjsyk@_oAK^GJ+3Oy+3zu>*sf_Tx3^L-2A<+I=S=FNQHyxA|_j+g2BxxZ)X zTJvq@(~h14LcImMj$j5IktP%5n`{BZe+M#&=jIa1?GZZs~b)=azqB3mPqqS z=shU*EPF|6`I+1S6@}I7hTjxwvk}!oHxRLv?_+1E(z~Dx$)M&`UC(eWe(~Qau%tC} zA#vlE)f(CGlTcUUcZF}PIIDEjr7$^Q>G<*+fC-E#=;(Uiz=Je1<%E8T&Bbf_ zSC(sG;T&)axDDKqjiK@Bwvsw-$T0$b7q|!Hf%^c4Mou~gmY9q{N#G&yDBc;WF}5zx z7H8S2>=eJVdAT?|c$m6eLCHF>0X$RCQ*!svY58k-H}?v;eqbN43T(!|N4A+peYWKG zvCmoRlUnSh0=YJNFiW*`I{9qK52I86-4%QIG_Wi)V?T1QA?FnIG*mJz^pWOU@x*wA zX)Wa2@@Agn&OSl@xGpO{|vk zC|NvVFCkWB*d=o4YS5u5k6t=->)_F#f1uy@4MdmEe1E^0_kQ2^eRJS{@l)-8x{jXA z%MYpD6Bmyp5()pRx8TSmDcA94T`AG@Lc{ZA2dSC)JBDk9u1rxO8(NET(&8LJ^<<}d zx=94)q7hnwSC?1r&RlZtM`1R@isBj;VH?XeJ>T$bah(b=4OD>}z`yOp&1gUOofU3T zH*6=257-<}aSt$oB7wuB7zE~`Zv$&>%v4oA&75e5e`V=qytoWJ03HI5)YJUvWRoPv zNd!!Z$G{UH3#gN87n8}P&d@?-im6CmHJ_-Y)j?KE8Q>9-2n7m&8ppUCbxqc@kv}(J*ZifMlBFJ+bwF*78o^gcIYob C!KHNo diff --git a/transports/native.py b/transports/native.py index 6eddf4b..2ed7ff9 100644 --- a/transports/native.py +++ b/transports/native.py @@ -10,6 +10,15 @@ def timestr(): return time.strftime("[%d/%m/%Y-%H:%M:%S]") +def new_to_old(s): + s = s.replace("'block_hash'", "'blk_hash'") + s = s.replace("'index'", "'pos'") + s = s.replace("'timestamp'", "'nTime'") + s = s.replace("'is_input'", "'is_in'") + s = s.replace("'raw_output_script'","'raw_scriptPubKey'") + return s + + class NativeServer(threading.Thread): def __init__(self, shared, abe, irc, banner, host, port): @@ -156,6 +165,7 @@ class NativeServer(threading.Thread): elif cmd == 'h': address = data out = repr( self.store.get_history( address ) ) + out = new_to_old(out) elif cmd =='tx': out = self.store.send_tx(data) -- 1.7.1