from . import base from source import packets, structures class PeerEvent(base.BaseEvent): """ Event reacting to receiving information about another machine """ def handle(self, packet: packets.PeerPacket, address: tuple): # ignore peers with a banned key if self.manager.communication.is_peer_banned(packet.public_key): return # TODO(Faraphel): SHOULD NOT BE TRUSTED AUTOMATICALLY ! self.manager.communication.trust_peer(packet.public_key) # update our peers database to add new peer information self.manager.peer.peers[address] = structures.Peer( public_key=packet.public_key, master=packet.master, trusted=self.manager.communication.is_peer_trusted(packet.public_key) )