commit af1bfa566ac86ce4e8b336694a3d256cc922c03b
parent 899f4e8c99a21b0fa0336f9405f44d49396c234e
Author: ThomasV <thomasv@gitorious>
Date: Mon, 14 Nov 2011 23:30:27 +0100
Merge branch 'master' of gitorious.org:electrum/electrum
Diffstat:
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/server/server.py b/server/server.py
@@ -323,7 +323,6 @@ def client_thread(ipaddr,conn):
print time.asctime(), "session", ipaddr, session_id, addresses[0], len(addresses)
- clean_sessions()
sessions[session_id] = {}
for a in addresses:
sessions[session_id][a] = ''
@@ -353,6 +352,9 @@ def client_thread(ipaddr,conn):
h = store.get_txpoints( addr )
out = repr(h)
+ elif cmd == 'load':
+ out = repr( len(sessions) )
+
elif cmd =='tx':
# transaction
out = send_tx(data)
@@ -398,13 +400,15 @@ def memorypool_update(store):
-def clean_sessions():
- t = time.time()
- for k,t0 in sessions_last_time.items():
- if t - t0 > 60:
- print "lost session",k
- sessions.pop(k)
- sessions_last_time.pop(k)
+def clean_session_thread():
+ while 1:
+ time.sleep(30)
+ t = time.time()
+ for k,t0 in sessions_last_time.items():
+ if t - t0 > 60:
+ print "lost session",k
+ sessions.pop(k)
+ sessions_last_time.pop(k)
@@ -413,6 +417,22 @@ import traceback
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"
conf = DataStore.CONFIG_DEFAULTS
args, argv = readconf.parse_argv( [], conf)
@@ -421,6 +441,7 @@ if __name__ == '__main__':
store = MyStore(args)
thread.start_new_thread(listen_thread, (store,))
+ thread.start_new_thread(clean_session_thread, ())
while True:
try: