Permalink
Browse files

Revert "broadcast shares in serial", strongly suspected of causing a …

…memory leak

This reverts commit 6f1a456.

Conflicts:

	p2pool/main.py
	p2pool/p2p.py
	p2pool/util/p2protocol.py
  • Loading branch information...
1 parent 0e325a4 commit 19bf4eac02eb3e12ca168ebc87f61f561e848d90 @forrestv forrestv committed Jan 27, 2013
Showing with 6 additions and 28 deletions.
  1. +2 −3 p2pool/node.py
  2. +4 −11 p2pool/p2p.py
  3. +0 −14 p2pool/util/p2protocol.py
View
@@ -76,7 +76,6 @@ def handle_bestblock(self, header, peer):
raise p2p.PeerMisbehavingError('received block header fails PoW test')
self.node.handle_header(header)
- @defer.inlineCallbacks
def broadcast_share(self, share_hash):
shares = []
for share in self.node.tracker.get_chain(share_hash, min(5, self.node.tracker.get_height(share_hash))):
@@ -85,8 +84,8 @@ def broadcast_share(self, share_hash):
self.shared_share_hashes.add(share.hash)
shares.append(share)
- for peer in list(self.peers.itervalues()):
- yield peer.sendShares([share for share in shares if share.peer_addr != peer.addr], self.node.tracker, self.node.known_txs_var.value, include_txs_with=[share_hash])
+ for peer in self.peers.itervalues():
+ peer.sendShares([share for share in shares if share.peer_addr != peer.addr], self.node.tracker, self.node.known_txs_var.value, include_txs_with=[share_hash])
def start(self):
p2p.Node.start(self)
View
@@ -19,10 +19,10 @@ class PeerMisbehavingError(Exception):
def fragment(f, **kwargs):
try:
- return f(**kwargs)
+ f(**kwargs)
except p2protocol.TooLong:
fragment(f, **dict((k, v[:len(v)//2]) for k, v in kwargs.iteritems()))
- return fragment(f, **dict((k, v[len(v)//2:]) for k, v in kwargs.iteritems()))
+ fragment(f, **dict((k, v[len(v)//2:]) for k, v in kwargs.iteritems()))
class Protocol(p2protocol.Protocol):
max_remembered_txs_size = 2500000
@@ -36,8 +36,6 @@ def __init__(self, node, incoming):
self.connected2 = False
def connectionMade(self):
- p2protocol.Protocol.connectionMade(self)
-
self.factory.proto_made_connection(self)
self.connection_lost_event = variable.Event()
@@ -260,9 +258,6 @@ 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)
def sendShares(self, shares, tracker, known_txs, include_txs_with=[]):
- if not shares:
- return defer.succeed(None)
-
if self.other_version >= 8:
tx_hashes = set()
for share in shares:
@@ -280,14 +275,12 @@ def sendShares(self, shares, tracker, known_txs, include_txs_with=[]):
fragment(self.send_remember_tx, tx_hashes=[x for x in hashes_to_send if x in self.remote_tx_hashes], txs=[known_txs[x] for x in hashes_to_send if x not in self.remote_tx_hashes])
- res = fragment(self.send_shares, shares=[share.as_share() for share in shares])
+ fragment(self.send_shares, shares=[share.as_share() for share in shares])
if self.other_version >= 8:
- res = self.send_forget_tx(tx_hashes=hashes_to_send)
+ self.send_forget_tx(tx_hashes=hashes_to_send)
self.remote_remembered_txs_size -= sum(100 + bitcoin_data.tx_type.packed_size(known_txs[x]) for x in hashes_to_send)
-
- return res
message_sharereq = pack.ComposedType([
View
@@ -19,21 +19,8 @@ def __init__(self, message_prefix, max_payload_length, traffic_happened=variable
self._message_prefix = message_prefix
self._max_payload_length = max_payload_length
self.dataReceived2 = datachunker.DataChunker(self.dataReceiver())
- self.paused_var = variable.Variable(False)
self.traffic_happened = traffic_happened
- def connectionMade(self):
- self.transport.registerProducer(self, True)
-
- def pauseProducing(self):
- self.paused_var.set(True)
-
- def resumeProducing(self):
- self.paused_var.set(False)
-
- def stopProducing(self):
- pass
-
def dataReceived(self, data):
self.traffic_happened.happened('p2p/in', len(data))
self.dataReceived2(data)
@@ -96,7 +83,6 @@ def sendPacket(self, command, payload2):
data = self._message_prefix + struct.pack('<12sI', command, len(payload)) + hashlib.sha256(hashlib.sha256(payload).digest()).digest()[:4] + payload
self.traffic_happened.happened('p2p/out', len(data))
self.transport.write(data)
- return self.paused_var.get_when_satisfies(lambda paused: not paused)
def __getattr__(self, attr):
prefix = 'send_'

0 comments on commit 19bf4ea

Please sign in to comment.