X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=backends%2Fabe%2F__init__.py;h=882c7931b4eab5dc7a41a854152e59dbb00add12;hb=9c5e46a690739443e131b0cf69a15c5eec46b50f;hp=82b99e3c8b858f98b7a6cba197e89bcbac645c8b;hpb=cf7aed705dbfeaa8b9e56a0649fd70f48d80d33f;p=electrum-server.git 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):