Merge branch 'master' of gitorious.org:electrum/electrum
This commit is contained in:
commit
642822187e
|
@ -90,9 +90,20 @@ address_queue = Queue()
|
||||||
|
|
||||||
class MyStore(Datastore_class):
|
class MyStore(Datastore_class):
|
||||||
|
|
||||||
def import_tx(self, tx, is_coinbase):
|
def import_block(self, b, chain_ids=frozenset()):
|
||||||
tx_id = super(MyStore, self).import_tx(tx, is_coinbase)
|
block_id = super(MyStore, self).import_block(b, chain_ids)
|
||||||
self.update_tx_cache(tx_id)
|
print "import block", block_id
|
||||||
|
for pos in xrange(len(b['transactions'])):
|
||||||
|
tx = b['transactions'][pos]
|
||||||
|
if 'hash' not in tx:
|
||||||
|
tx['hash'] = util.double_sha256(tx['tx'])
|
||||||
|
tx_id = store.tx_find_id_and_value(tx)
|
||||||
|
if tx_id:
|
||||||
|
self.update_tx_cache(tx_id)
|
||||||
|
else:
|
||||||
|
print "error: import_block: no tx_id"
|
||||||
|
return block_id
|
||||||
|
|
||||||
|
|
||||||
def update_tx_cache(self, txid):
|
def update_tx_cache(self, txid):
|
||||||
inrows = self.get_tx_inputs(txid, False)
|
inrows = self.get_tx_inputs(txid, False)
|
||||||
|
@ -715,8 +726,8 @@ def tcp_client_thread(ipaddr,conn):
|
||||||
print "json error", repr(c)
|
print "json error", repr(c)
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
cmd = c['method']
|
cmd = c.get('method')
|
||||||
data = c['params']
|
data = c.get('params')
|
||||||
except:
|
except:
|
||||||
print "syntax error", repr(c), ipaddr
|
print "syntax error", repr(c), ipaddr
|
||||||
continue
|
continue
|
||||||
|
@ -774,7 +785,6 @@ def process_output_queue():
|
||||||
|
|
||||||
|
|
||||||
def memorypool_update(store):
|
def memorypool_update(store):
|
||||||
""" when a tx is removed from memory pool, I need to notify subscribers"""
|
|
||||||
|
|
||||||
ds = BCDataStream.BCDataStream()
|
ds = BCDataStream.BCDataStream()
|
||||||
previous_transactions = store.mempool_keys
|
previous_transactions = store.mempool_keys
|
||||||
|
@ -798,15 +808,10 @@ def memorypool_update(store):
|
||||||
if store.tx_find_id_and_value(tx):
|
if store.tx_find_id_and_value(tx):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
store.import_tx(tx, False)
|
tx_id = store.import_tx(tx, False)
|
||||||
store.commit()
|
store.update_tx_cache(tx_id)
|
||||||
|
|
||||||
for tx_hash in previous_transactions:
|
store.commit()
|
||||||
if tx_hash not in store.mempool_keys:
|
|
||||||
tx = { 'hash':store.hashout(tx_hash) }
|
|
||||||
tx_id = store.tx_find_id_and_value(tx)
|
|
||||||
if tx_id:
|
|
||||||
store.update_tx_cache(tx_id)
|
|
||||||
|
|
||||||
|
|
||||||
def clean_session_thread():
|
def clean_session_thread():
|
||||||
|
@ -945,8 +950,8 @@ if __name__ == '__main__':
|
||||||
dblock.acquire()
|
dblock.acquire()
|
||||||
store.catch_up()
|
store.catch_up()
|
||||||
memorypool_update(store)
|
memorypool_update(store)
|
||||||
block_number = store.get_block_number(1)
|
|
||||||
|
|
||||||
|
block_number = store.get_block_number(1)
|
||||||
if block_number != old_block_number:
|
if block_number != old_block_number:
|
||||||
old_block_number = block_number
|
old_block_number = block_number
|
||||||
for session_id in sessions_sub_numblocks:
|
for session_id in sessions_sub_numblocks:
|
||||||
|
|
Loading…
Reference in New Issue