Skip to content

Commit

Permalink
don't send irc messages if not in #p2pool channel
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestv committed Oct 17, 2012
1 parent 53cac86 commit a2c788b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions p2pool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,14 @@ def lineReceived(self, line):
print repr(line)
irc.IRCClient.lineReceived(self, line)
def signedOn(self):
self.in_channel = False
irc.IRCClient.signedOn(self)
self.factory.resetDelay()
self.join(self.channel)
@defer.inlineCallbacks
def new_share(share):
if not self.in_channel:
return
if share.pow_hash <= share.header['bits'].target and abs(share.timestamp - time.time()) < 10*60:
yield deferral.sleep(random.expovariate(1/60))
message = '\x02%s BLOCK FOUND by %s! %s%064x' % (net.NAME.upper(), bitcoin_data.script2_to_address(share.new_script, net.PARENT), net.PARENT.BLOCK_EXPLORER_URL_PREFIX, share.header_hash)
Expand All @@ -522,6 +525,10 @@ def new_share(share):
self._remember_message(message)
self.watch_id = tracker.verified.added.watch(new_share)
self.recent_messages = []
def joined(self, channel):
self.in_channel = True
def left(self, channel):
self.in_channel = False
def _remember_message(self, message):
self.recent_messages.append(message)
while len(self.recent_messages) > 100:
Expand Down

0 comments on commit a2c788b

Please sign in to comment.