Ejemplo n.º 1
0
 def handle_shares(self, shares):
     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)
Ejemplo n.º 2
0
    def handle_shares(self, shares):
        result = []
        for wrappedshare in shares:
            if wrappedshare['type'] < p2pool_data.Share.VERSION: 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)
Ejemplo n.º 3
0
 def handle_sharereply(self, id, result, shares):
     if result == 'good':
         res = [
             p2pool_data.load_share(share, self.node.net, self.addr)
             for share in shares if share['type'] >= 9
         ]
     else:
         res = failure.Failure(self.ShareReplyError(result))
     self.get_shares.got_response(id, res)
Ejemplo n.º 4
0
 def handle_sharereply(self, id, result, shares):
     if result == 'good':
         res = [
             p2pool_data.load_share(share, self.node.net, self)
             for share in shares if share['type'] not in [6, 7]
         ]
     else:
         res = failure.Failure("sharereply result: " + result)
     self.get_shares.got_response(id, res)
Ejemplo n.º 5
0
Archivo: p2p.py Proyecto: p2pool/p2pool
 def handle_sharereply(self, id, result, shares):
     if result == "good":
         res = [
             p2pool_data.load_share(share, self.node.net, self.addr)
             for share in shares
             if share["type"] >= p2pool_data.Share.VERSION
         ]
     else:
         res = failure.Failure(self.ShareReplyError(result))
     self.get_shares.got_response(id, res)
Ejemplo n.º 6
0
    def handle_shares(self, shares):
        t0 = time.time()
        result = []
        for wrappedshare in shares:
            if wrappedshare['type'] < p2pool_data.Share.VERSION: 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]
                                if p2pool.DEBUG:
                                    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)
        t1 = time.time()
        if p2pool.BENCH:
            print "%8.3f ms for %i shares in handle_shares (%3.3f ms/share)" % (
                (t1 - t0) * 1000., len(shares),
                (t1 - t0) * 1000. / max(1, len(shares)))
Ejemplo n.º 7
0
 def handle_sharereply(self, id, result, shares):
     if result == 'good':
         res = [p2pool_data.load_share(share, self.node.net, self.addr) for share in shares if share['type'] >= 9]
     else:
         res = failure.Failure("sharereply result: " + result)
     self.get_shares.got_response(id, res)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 def handle_shares(self, shares):
     self.node.handle_shares([p2pool_data.load_share(share, self.node.net, self) for share in shares if share['type'] not in [6, 7]], self)
Ejemplo n.º 10
0
Archivo: p2p.py Proyecto: GTRsdk/p2pool
 def handle_shares(self, shares):
     self.node.handle_shares([p2pool_data.load_share(share, self.node.net, self) for share in shares], self)
Ejemplo n.º 11
0
 def handle_shares(self, shares):
     self.node.handle_shares([
         p2pool_data.load_share(share, self.node.net, self)
         for share in shares if share['type'] >= 9
     ], self)