diff --git a/teos/extended_appointment.py b/teos/extended_appointment.py index 101b93b..7aa4482 100644 --- a/teos/extended_appointment.py +++ b/teos/extended_appointment.py @@ -6,6 +6,15 @@ class ExtendedAppointment(Appointment): super().__init__(locator, to_self_delay, encrypted_blob) self.user_id = user_id + def get_summary(self): + """ + Returns the summary of an appointment, consisting on the locator, the user_id and the appointment size. + + Returns: + :obj:`dict`: the appointment summary. + """ + return {"locator": self.locator, "user_id": self.user_id, "size": len(self.encrypted_blob)} + @classmethod def from_dict(cls, appointment_data): """ diff --git a/teos/watcher.py b/teos/watcher.py index 729c652..32b951e 100644 --- a/teos/watcher.py +++ b/teos/watcher.py @@ -128,11 +128,12 @@ class Watcher: # The uuids are generated as the RIPMED160(locator||user_pubkey). # If an appointment is requested by the user the uuid can be recomputed and queried straightaway (no maps). uuid = hash_160("{}{}".format(appointment.locator, user_id)) - appointment_dict = {"locator": appointment.locator, "user_id": user_id, "size": len(appointment.encrypted_blob)} - available_slots = self.gatekeeper.update_available_slots(user_id, appointment_dict, self.appointments.get(uuid)) + available_slots = self.gatekeeper.update_available_slots( + user_id, appointment.get_summary(), self.appointments.get(uuid) + ) self.gatekeeper.registered_users[user_id].appointments.append(uuid) - self.appointments[uuid] = appointment_dict + self.appointments[uuid] = appointment.get_summary() if appointment.locator in self.locator_uuid_map: # If the uuid is already in the map it means this is an update.