import sys
import time
-from twisted.internet import protocol, task
+from twisted.internet import protocol
import p2pool
from . import data as bitcoin_data
class Protocol(p2protocol.Protocol):
def __init__(self, net):
- p2protocol.Protocol.__init__(self, net.P2P_PREFIX, 1000000)
+ p2protocol.Protocol.__init__(self, net.P2P_PREFIX, 1000000, ignore_trailing_payload=True)
def connectionMade(self):
self.send_version(
- version=32200,
+ version=70002,
services=1,
time=int(time.time()),
addr_to=dict(
if hasattr(self.factory, 'gotConnection'):
self.factory.gotConnection(self)
- self.pinger = task.LoopingCall(self.send_ping)
+ self.pinger = deferral.RobustLoopingCall(self.send_ping, nonce=1234)
self.pinger.start(30)
message_inv = pack.ComposedType([
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([