mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-29 16:31:29 +00:00
Merge branch 'master' of git://gitorious.org/electrum/electrum
This commit is contained in:
commit
db0725bdcd
1 changed files with 18 additions and 5 deletions
|
@ -673,6 +673,13 @@ def tcp_server_thread():
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
|
|
||||||
|
|
||||||
|
def close_session(session_id):
|
||||||
|
print "lost connection", session_id
|
||||||
|
sessions.pop(session_id)
|
||||||
|
if session_id in sessions_sub_numblocks:
|
||||||
|
sessions_sub_numblocks.remove(session_id)
|
||||||
|
|
||||||
|
|
||||||
# one thread per client. put requests in a queue.
|
# one thread per client. put requests in a queue.
|
||||||
def tcp_client_thread(ipaddr,conn):
|
def tcp_client_thread(ipaddr,conn):
|
||||||
""" use a persistent connection. put commands in a queue."""
|
""" use a persistent connection. put commands in a queue."""
|
||||||
|
@ -689,9 +696,7 @@ def tcp_client_thread(ipaddr,conn):
|
||||||
d = conn.recv(1024)
|
d = conn.recv(1024)
|
||||||
msg += d
|
msg += d
|
||||||
if not d:
|
if not d:
|
||||||
print "lost connection", session_id
|
close_session(session_id)
|
||||||
sessions.pop(session_id)
|
|
||||||
sessions_sub_numblocks.remove(session_id)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -717,6 +722,8 @@ def tcp_client_thread(ipaddr,conn):
|
||||||
def process_input_queue():
|
def process_input_queue():
|
||||||
while not stopping:
|
while not stopping:
|
||||||
session_id, cmd, data = input_queue.get()
|
session_id, cmd, data = input_queue.get()
|
||||||
|
if session_id not in sessions.keys():
|
||||||
|
continue
|
||||||
out = None
|
out = None
|
||||||
if cmd == 'address.subscribe':
|
if cmd == 'address.subscribe':
|
||||||
subscribe_to_address(session_id,data)
|
subscribe_to_address(session_id,data)
|
||||||
|
@ -726,6 +733,8 @@ def process_input_queue():
|
||||||
sessions[session_id]['version'] = data
|
sessions[session_id]['version'] = data
|
||||||
elif cmd == 'server.banner':
|
elif cmd == 'server.banner':
|
||||||
out = json.dumps( { 'method':'server.banner', 'result':config.get('server','banner').replace('\\n','\n') } )
|
out = json.dumps( { 'method':'server.banner', 'result':config.get('server','banner').replace('\\n','\n') } )
|
||||||
|
elif cmd == 'server.peers':
|
||||||
|
out = json.dumps( { 'method':'server.peers', 'result':peer_list.values() } )
|
||||||
elif cmd == 'address.get_history':
|
elif cmd == 'address.get_history':
|
||||||
address = data
|
address = data
|
||||||
out = json.dumps( { 'method':'address.get_history', 'address':address, 'result':store.get_history( address ) } )
|
out = json.dumps( { 'method':'address.get_history', 'address':address, 'result':store.get_history( address ) } )
|
||||||
|
@ -744,8 +753,12 @@ def process_output_queue():
|
||||||
session_id, out = output_queue.get()
|
session_id, out = output_queue.get()
|
||||||
session = sessions.get(session_id)
|
session = sessions.get(session_id)
|
||||||
if session:
|
if session:
|
||||||
|
try:
|
||||||
conn = session.get('conn')
|
conn = session.get('conn')
|
||||||
conn.send(out+'\n')
|
conn.send(out+'\n')
|
||||||
|
except:
|
||||||
|
close_session(session_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue