示例#1
0
 def __init__(self):
     #basic.LineOnlyReceiver.__init__(self)
     self._matcher = deferral.GenericDeferrer(max_id=2**30, func=lambda id, method, params: self.sendLine(json.dumps({
         'jsonrpc': '2.0',
         'method': method,
         'params': params,
         'id': id,
     })))
     self.other = Proxy(self._matcher)
示例#2
0
    def connectionMade(self):
        p2protocol.Protocol.connectionMade(self)

        self.factory.proto_made_connection(self)

        self.connection_lost_event = variable.Event()

        self.addr = self.transport.getPeer().host, self.transport.getPeer(
        ).port

        self.send_version(
            version=901,
            services=0,
            addr_to=dict(
                services=0,
                address=self.transport.getPeer().host,
                port=self.transport.getPeer().port,
            ),
            addr_from=dict(
                services=0,
                address=self.transport.getHost().host,
                port=self.transport.getHost().port,
            ),
            nonce=self.node.nonce,
            sub_version=p2pool.__version__,
            mode=1,
            best_share_hash=self.node.best_share_hash_func(),
        )

        self.timeout_delayed = reactor.callLater(10, self._connect_timeout)

        self.get_shares = deferral.GenericDeferrer(
            max_id=2**256,
            func=lambda id, hashes, parents, stops: self.send_sharereq(
                id=id, hashes=hashes, parents=parents, stops=stops),
            timeout=15,
            on_timeout=self.transport.loseConnection,
        )

        self.remote_tx_hashes = set(
        )  # view of peer's known_txs # not actually initially empty, but sending txs instead of tx hashes won't hurt
        self.remote_remembered_txs_size = 0

        self.remembered_txs = {}  # view of peer's mining_txs
        self.remembered_txs_size = 0
        self.known_txs_cache = {}
示例#3
0
文件: p2p.py 项目: alaudidae/p2pool
    def connectionMade(self):
        p2protocol.Protocol.connectionMade(self)

        self.factory.proto_made_connection(self)

        self.addr = self.transport.getPeer().host, self.transport.getPeer(
        ).port

        self.send_version(
            version=4,
            services=0,
            addr_to=dict(
                services=0,
                address=self.transport.getPeer().host,
                port=self.transport.getPeer().port,
            ),
            addr_from=dict(
                services=0,
                address=self.transport.getHost().host,
                port=self.transport.getHost().port,
            ),
            nonce=self.node.nonce,
            sub_version=p2pool.__version__,
            mode=1,
            best_share_hash=self.node.best_share_hash_func(),
        )

        self.timeout_delayed = reactor.callLater(10, self._connect_timeout)

        self.get_shares = deferral.GenericDeferrer(
            max_id=2**256,
            func=lambda id, hashes, parents, stops: self.send_sharereq(
                id=id, hashes=hashes, parents=parents, stops=stops),
            timeout=15,
            on_timeout=self.transport.loseConnection,
        )