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):
        # update our peers database to add new peer information
        self.manager.peer.peers[address] = structures.Peer(
            public_key=packet.public_key,
            master=packet.master,
        )
