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)
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:

Loading…
Cancel
Save