Litecoin servers login to IRC with user name starting with EL_
[electrum-server.git] / backends / irc / __init__.py
index edd9dc9..bd981a3 100644 (file)
@@ -5,7 +5,7 @@ def random_string(N):
     return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(N))
 
 from processor import Processor
-
+from version import VERSION
 
 class IrcThread(threading.Thread):
 
@@ -25,7 +25,7 @@ class IrcThread(threading.Thread):
 
 
     def getname(self):
-        s = ''
+        s = 'v' + VERSION + ' '
         if self.stratum_tcp_port:
             s += 't' + self.stratum_tcp_port + ' ' 
         if self.stratum_http_port:
@@ -41,7 +41,7 @@ class IrcThread(threading.Thread):
                 s = socket.socket()
                 s.connect(('irc.freenode.net', 6667))
                 s.send('USER electrum 0 * :' + self.host + ' ' + ircname + '\n')
-                s.send('NICK E_' + self.nick + '\n')
+                s.send('NICK EL_' + self.nick + '\n')
                 s.send('JOIN #electrum\n')
                 sf = s.makefile('r', 0)
                 t = 0
@@ -49,12 +49,13 @@ class IrcThread(threading.Thread):
                     line = sf.readline()
                     line = line.rstrip('\r\n')
                     line = line.split()
+                    if not line: continue
                     if line[0]=='PING': 
                         s.send('PONG '+line[1]+'\n')
                     elif '353' in line: # answer to /names
                         k = line.index('353')
                         for item in line[k+1:]:
-                            if item[0:2] == 'E_':
+                            if item[0:2] == 'EL_':
                                 s.send('WHO %s\n'%item)
                     elif '352' in line: # answer to /who
                         # warning: this is a horrible hack which apparently works
@@ -129,7 +130,7 @@ class ServerProcessor(Processor):
             result = self.get_peers()
 
         elif method == 'server.version':
-            result = 'ok'
+            result = VERSION
 
         elif method == 'server.stop':
             self.shared.stop()
@@ -143,6 +144,10 @@ class ServerProcessor(Processor):
                                      "subscriptions":len(s.subscriptions)}, 
                          self.dispatcher.request_dispatcher.get_sessions())
 
+        elif method == 'server.cache':
+            p = self.dispatcher.request_dispatcher.processors['blockchain']
+            result = len(repr(p.store.tx_cache))
+
         elif method == 'server.load':
             p = self.dispatcher.request_dispatcher.processors['blockchain']
             result = p.queue.qsize()