raw
9982-getdata            1 import logging
9982-getdata 2 import time
9982-getdata 3 import hashlib
9982-getdata 4 import os
9982-getdata 5 from message import Message
9982-getdata 6 from message import IGNORE
9982-getdata 7
9982-getdata 8
9982-getdata 9 class Ignore(Message):
9982-getdata 10 def __init__(self, message, state):
9982-getdata 11 message['command'] = IGNORE
9982-getdata 12 message['bounces'] = 0
9982-getdata 13 message['body'] = self.gen_rubbish_body()
9982-getdata 14 super(Ignore, self).__init__(message, state)
9982-getdata 15
9982-getdata 16 def send(self):
9982-getdata 17 if not self.speaker:
9982-getdata 18 logging.error("aborting message send due speaker not being set")
9982-getdata 19 return
9982-getdata 20
9982-getdata 21 # if we are not rebroadcasting we need to set the timestamp
9982-getdata 22 self.timestamp = int(time.time())
9982-getdata 23 self.message_bytes = self.get_message_bytes()
9982-getdata 24 self.message_hash = hashlib.sha256(self.message_bytes).digest()
9982-getdata 25
9982-getdata 26 for peer in self.state.get_keyed_peers(exclude_addressless=True):
9982-getdata 27 signed_packet_bytes = self.pack(peer, self.command, self.bounces, self.message_bytes)
9982-getdata 28 peer.send(signed_packet_bytes)
9982-getdata 29 if os.environ.get('LOG_RUBBISH'):
9982-getdata 30 self.log_rubbish(peer)