import logging import time import hashlib import os from message import Message from message import IGNORE class Ignore(Message): def __init__(self, message, state): message['command'] = IGNORE message['bounces'] = 0 message['body'] = self.gen_rubbish_body() super(Ignore, self).__init__(message, state) def send(self): if not self.speaker: logging.error("aborting message send due speaker not being set") return # if we are not rebroadcasting we need to set the timestamp self.timestamp = int(time.time()) self.message_bytes = self.get_message_bytes() self.message_hash = hashlib.sha256(self.message_bytes).digest() for peer in self.state.get_keyed_peers(exclude_addressless=True): signed_packet_bytes = self.pack(peer, self.command, self.bounces, self.message_bytes) peer.send(signed_packet_bytes) if os.environ.get('LOG_RUBBISH'): self.log_rubbish(peer)