Browse Source

Merge branch 'master' of gitorious.org:electrum/electrum

283
ThomasV 13 years ago
parent
commit
af1bfa566a
  1. 37
      server/server.py

37
server/server.py

@ -323,7 +323,6 @@ def client_thread(ipaddr,conn):
print time.asctime(), "session", ipaddr, session_id, addresses[0], len(addresses) print time.asctime(), "session", ipaddr, session_id, addresses[0], len(addresses)
clean_sessions()
sessions[session_id] = {} sessions[session_id] = {}
for a in addresses: for a in addresses:
sessions[session_id][a] = '' sessions[session_id][a] = ''
@ -353,6 +352,9 @@ def client_thread(ipaddr,conn):
h = store.get_txpoints( addr ) h = store.get_txpoints( addr )
out = repr(h) out = repr(h)
elif cmd == 'load':
out = repr( len(sessions) )
elif cmd =='tx': elif cmd =='tx':
# transaction # transaction
out = send_tx(data) out = send_tx(data)
@ -398,13 +400,15 @@ def memorypool_update(store):
def clean_sessions(): def clean_session_thread():
t = time.time() while 1:
for k,t0 in sessions_last_time.items(): time.sleep(30)
if t - t0 > 60: t = time.time()
print "lost session",k for k,t0 in sessions_last_time.items():
sessions.pop(k) if t - t0 > 60:
sessions_last_time.pop(k) print "lost session",k
sessions.pop(k)
sessions_last_time.pop(k)
@ -413,6 +417,22 @@ import traceback
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv)>1:
request = sys.argv[1]
request += "#"
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
s.connect(( HOST, PORT))
s.send( request )
out = ''
while 1:
msg = s.recv(1024)
if msg: out += msg
else: break
s.close()
print out
sys.exit(0)
print "starting Electrum server" print "starting Electrum server"
conf = DataStore.CONFIG_DEFAULTS conf = DataStore.CONFIG_DEFAULTS
args, argv = readconf.parse_argv( [], conf) args, argv = readconf.parse_argv( [], conf)
@ -421,6 +441,7 @@ if __name__ == '__main__':
store = MyStore(args) store = MyStore(args)
thread.start_new_thread(listen_thread, (store,)) thread.start_new_thread(listen_thread, (store,))
thread.start_new_thread(clean_session_thread, ())
while True: while True:
try: try:

Loading…
Cancel
Save