Просмотр исходного кода

protocol: add newline at end of hello and JSON messages

Malte Kraus 8 лет назад
Родитель
Сommit
e624ec94fc
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      src/protocol.py

+ 2 - 2
src/protocol.py

@@ -19,7 +19,7 @@ __all__ = ['Protocol', 'PeerConnection', 'MAX_PEERS', 'HELLO_MSG']
 MAX_PEERS = 10
 MAX_PEERS = 10
 """ The maximum number of peers that we connect to."""
 """ The maximum number of peers that we connect to."""
 
 
-HELLO_MSG = b"bl0ckch41n" + hexlify(GENESIS_BLOCK_HASH)[:30]
+HELLO_MSG = b"bl0ckch41n" + hexlify(GENESIS_BLOCK_HASH)[:30] + b"\n"
 """ The hello message two peers use to make sure they are speaking the same protocol. """
 """ The hello message two peers use to make sure they are speaking the same protocol. """
 
 
 SOCKET_TIMEOUT = 30
 SOCKET_TIMEOUT = 30
@@ -137,7 +137,7 @@ class PeerConnection:
             item = self.outgoing_msgs.get()
             item = self.outgoing_msgs.get()
             if item is None:
             if item is None:
                 break
                 break
-            data = json.dumps(item, indent=4).encode()
+            data = json.dumps(item, indent=4).encode() + b"\n"
             self.socket.sendall(str(len(data)).encode() + b"\n" + data)
             self.socket.sendall(str(len(data)).encode() + b"\n" + data)
             self.outgoing_msgs.task_done()
             self.outgoing_msgs.task_done()