maintain a list of mempool keys; the database might contain rejected transactions
This commit is contained in:
@@ -249,6 +249,8 @@ class MyStore(Datastore_class):
|
|||||||
tx_hash = self.hashout_hex(tx_hash)
|
tx_hash = self.hashout_hex(tx_hash)
|
||||||
if tx_hash in known_tx:
|
if tx_hash in known_tx:
|
||||||
continue
|
continue
|
||||||
|
if tx_hash not in self.mempool_keys:
|
||||||
|
continue
|
||||||
|
|
||||||
address_has_mempool = True
|
address_has_mempool = True
|
||||||
#print "mempool", tx_hash
|
#print "mempool", tx_hash
|
||||||
@@ -362,12 +364,13 @@ def client_thread(ipaddr,conn):
|
|||||||
version = "old"
|
version = "old"
|
||||||
else:
|
else:
|
||||||
version, addresses = ast.literal_eval(data)
|
version, addresses = ast.literal_eval(data)
|
||||||
|
version = "v"+version
|
||||||
except:
|
except:
|
||||||
print "error"
|
print "error", data
|
||||||
conn.close()
|
conn.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
print time.strftime("[%d/%m/%Y-%H:%M:%S]"), "new session", ipaddr, addresses[0] if addresses else addresses, len(addresses), "v"+version
|
print time.strftime("[%d/%m/%Y-%H:%M:%S]"), "new session", ipaddr, addresses[0] if addresses else addresses, len(addresses), version
|
||||||
|
|
||||||
sessions[session_id] = { 'addresses':{}, 'version':version, 'ip':ipaddr }
|
sessions[session_id] = { 'addresses':{}, 'version':version, 'ip':ipaddr }
|
||||||
for a in addresses:
|
for a in addresses:
|
||||||
@@ -495,6 +498,7 @@ ds = BCDataStream.BCDataStream()
|
|||||||
|
|
||||||
|
|
||||||
def memorypool_update(store):
|
def memorypool_update(store):
|
||||||
|
store.mempool_keys = []
|
||||||
conn = bitcoinrpc.connect_to_local()
|
conn = bitcoinrpc.connect_to_local()
|
||||||
try:
|
try:
|
||||||
v = conn.getmemorypool()
|
v = conn.getmemorypool()
|
||||||
@@ -507,17 +511,16 @@ def memorypool_update(store):
|
|||||||
ds.write(hextx.decode('hex'))
|
ds.write(hextx.decode('hex'))
|
||||||
tx = deserialize.parse_Transaction(ds)
|
tx = deserialize.parse_Transaction(ds)
|
||||||
tx['hash'] = util.double_sha256(tx['tx'])
|
tx['hash'] = util.double_sha256(tx['tx'])
|
||||||
|
store.mempool_keys.append(tx['hash'][::-1].encode('hex'))
|
||||||
if store.tx_find_id_and_value(tx):
|
if store.tx_find_id_and_value(tx):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
#print "new tx", tx['hash'][::-1].encode('hex')
|
|
||||||
store.import_tx(tx, False)
|
store.import_tx(tx, False)
|
||||||
|
|
||||||
store.commit()
|
store.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def clean_session_thread():
|
def clean_session_thread():
|
||||||
while not stopping:
|
while not stopping:
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
@@ -621,6 +624,7 @@ if __name__ == '__main__':
|
|||||||
store = MyStore(args)
|
store = MyStore(args)
|
||||||
store.tx_cache = {}
|
store.tx_cache = {}
|
||||||
store.ismempool = False
|
store.ismempool = False
|
||||||
|
store.mempool_keys = {}
|
||||||
|
|
||||||
thread.start_new_thread(listen_thread, (store,))
|
thread.start_new_thread(listen_thread, (store,))
|
||||||
thread.start_new_thread(clean_session_thread, ())
|
thread.start_new_thread(clean_session_thread, ())
|
||||||
|
|||||||
Reference in New Issue
Block a user