From: ThomasV Date: Sat, 20 Oct 2012 10:38:16 +0000 (+0400) Subject: support new unpatched bitcoind X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=commitdiff_plain;h=9c5e46a690739443e131b0cf69a15c5eec46b50f support new unpatched bitcoind --- diff --git a/backends/abe/__init__.py b/backends/abe/__init__.py index 82b99e3..882c793 100644 --- a/backends/abe/__init__.py +++ b/backends/abe/__init__.py @@ -48,6 +48,7 @@ class AbeStore(Datastore_class): self.dblock = thread.allocate_lock() self.last_tx_id = 0 + self.known_mempool_hashes = [] def import_tx(self, tx, is_coinbase): @@ -465,29 +466,39 @@ class AbeStore(Datastore_class): def memorypool_update(store): ds = BCDataStream.BCDataStream() - postdata = dumps({"method": 'getmemorypool', 'params': [], 'id':'jsonrpc'}) - + postdata = dumps({"method": 'getrawmempool', 'params': [], 'id':'jsonrpc'}) respdata = urllib.urlopen(store.bitcoind_url, postdata).read() r = loads(respdata) if r['error'] != None: + print r['error'] return - v = r['result'].get('transactions') - for hextx in v: + mempool_hashes = r.get('result') + for tx_hash in mempool_hashes: + + if tx_hash in store.known_mempool_hashes: continue + store.known_mempool_hashes.append(tx_hash) + + postdata = dumps({"method": 'getrawtransaction', 'params': [tx_hash], 'id':'jsonrpc'}) + respdata = urllib.urlopen(store.bitcoind_url, postdata).read() + r = loads(respdata) + if r['error'] != None: + continue + hextx = r.get('result') ds.clear() ds.write(hextx.decode('hex')) tx = deserialize.parse_Transaction(ds) tx['hash'] = util.double_sha256(tx['tx']) - tx_hash = store.hashin(tx['hash']) - + if store.tx_find_id_and_value(tx): pass else: tx_id = store.import_tx(tx, False) store.update_tx_cache(tx_id) #print tx_hash - + store.commit() + store.known_mempool_hashes = mempool_hashes def send_tx(self,tx):