From: Forrest Voight Date: Mon, 4 Nov 2013 16:03:32 +0000 (-0500) Subject: added nonce to bitcoin p2p ping/pong messages to fix errors in bitcoind.log X-Git-Tag: 13.4~6 X-Git-Url: https://git.novaco.in/?p=p2pool.git;a=commitdiff_plain;h=ae8740b9d8a417e6b4fd119f2cc646d86d0ae639;hp=b2eb3d26b52b38d17c0bd5febf0b727ea9550090 added nonce to bitcoin p2p ping/pong messages to fix errors in bitcoind.log --- diff --git a/p2pool/bitcoin/p2p.py b/p2pool/bitcoin/p2p.py index e7086b3..d6f50c2 100644 --- a/p2pool/bitcoin/p2p.py +++ b/p2pool/bitcoin/p2p.py @@ -59,7 +59,7 @@ class Protocol(p2protocol.Protocol): if hasattr(self.factory, 'gotConnection'): self.factory.gotConnection(self) - self.pinger = deferral.RobustLoopingCall(self.send_ping) + self.pinger = deferral.RobustLoopingCall(self.send_ping, nonce=1234) self.pinger.start(30) message_inv = pack.ComposedType([ @@ -128,8 +128,16 @@ class Protocol(p2protocol.Protocol): self.get_block_header.got_response(bitcoin_data.hash256(bitcoin_data.block_header_type.pack(header)), header) self.factory.new_headers.happened([header['header'] for header in headers]) - message_ping = pack.ComposedType([]) - def handle_ping(self): + message_ping = pack.ComposedType([ + ('nonce', pack.IntType(64)), + ]) + def handle_ping(self, nonce): + self.send_pong(nonce=nonce) + + message_pong = pack.ComposedType([ + ('nonce', pack.IntType(64)), + ]) + def handle_pong(self, nonce): pass message_alert = pack.ComposedType([