X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=p2pool%2Fp2p.py;h=bc61982eca3c0548e4f19aa7f18d6fef705230c9;hb=9541a77695bc98cccff001541ccb3880bca6d875;hp=189fd2c1b0e533d5d416cc9f80506cbb01c681c6;hpb=90574e6a152ffe4277de3c351ad75032d3a0dea7;p=p2pool.git diff --git a/p2pool/p2p.py b/p2pool/p2p.py index 189fd2c..bc61982 100644 --- a/p2pool/p2p.py +++ b/p2pool/p2p.py @@ -116,7 +116,7 @@ class Protocol(p2protocol.Protocol): def handle_version(self, version, services, addr_to, addr_from, nonce, sub_version, mode, best_share_hash): if self.other_version is not None: raise PeerMisbehavingError('more than one version message') - if version < 8: + if version < 1300: raise PeerMisbehavingError('peer too old') self.other_version = version @@ -252,11 +252,43 @@ class Protocol(p2protocol.Protocol): ('shares', pack.ListType(p2pool_data.share_type)), ]) def handle_shares(self, shares): - self.node.handle_shares([p2pool_data.load_share(share, self.node.net, self.addr) for share in shares if share['type'] >= 9], self) + result = [] + for wrappedshare in shares: + if wrappedshare['type'] < 9: continue + share = p2pool_data.load_share(wrappedshare, self.node.net, self.addr) + if wrappedshare['type'] >= 13: + txs = [] + for tx_hash in share.share_info['new_transaction_hashes']: + if tx_hash in self.node.known_txs_var.value: + tx = self.node.known_txs_var.value[tx_hash] + else: + for cache in self.known_txs_cache.itervalues(): + if tx_hash in cache: + tx = cache[tx_hash] + print 'Transaction %064x rescued from peer latency cache!' % (tx_hash,) + break + else: + print >>sys.stderr, 'Peer referenced unknown transaction %064x, disconnecting' % (tx_hash,) + self.disconnect() + return + txs.append(tx) + else: + txs = None + + result.append((share, txs)) + + self.node.handle_shares(result, self) def sendShares(self, shares, tracker, known_txs, include_txs_with=[]): tx_hashes = set() for share in shares: + if share.VERSION >= 13: + # send full transaction for every new_transaction_hash that peer does not know + for tx_hash in share.share_info['new_transaction_hashes']: + assert tx_hash in known_txs, 'tried to broadcast share without knowing all its new transactions' + if tx_hash not in self.remote_tx_hashes: + tx_hashes.add(tx_hash) + continue if share.hash in include_txs_with: x = share.get_other_tx_hashes(tracker) if x is not None: