diff --git a/contrib/pyln-client/pyln/client/gossmap.py b/contrib/pyln-client/pyln/client/gossmap.py index 5c995219e6c3..18bee0a1057a 100755 --- a/contrib/pyln-client/pyln/client/gossmap.py +++ b/contrib/pyln-client/pyln/client/gossmap.py @@ -100,10 +100,10 @@ def __init__(self, self.satoshis = None self.half_channels: List[Optional[GossmapHalfchannel]] = [None, None] - def update_channel(self, - direction: int, - fields: Dict[str, Any], - off: int): + def _update_channel(self, + direction: int, + fields: Dict[str, Any], + off: int): self.updates_fields[direction] = fields self.updates_offset[direction] = off @@ -183,7 +183,7 @@ def _del_channel(self, scid: ShortChannelId): if len(n2.channels): del self.nodes[c.node2_id] - def add_channel(self, rec: bytes, off: int, is_private: bool): + def _add_channel(self, rec: bytes, off: int, is_private: bool): fields = channel_announcement.read(io.BytesIO(rec[2:]), {}) # Add nodes one the fly node1_id = GossmapNodeId(fields['node_id_1']) @@ -214,13 +214,13 @@ def get_node(self, node_id: Union[GossmapNodeId, str]): node_id = GossmapNodeId.from_str(node_id) return self.nodes.get(cast(GossmapNodeId, node_id)) - def update_channel(self, rec: bytes, off: int): + def _update_channel(self, rec: bytes, off: int): fields = channel_update.read(io.BytesIO(rec[2:]), {}) direction = fields['channel_flags'] & 1 c = self.channels[ShortChannelId.from_int(fields['short_channel_id'])] - c.update_channel(direction, fields, off) + c._update_channel(direction, fields, off) - def add_node_announcement(self, rec: bytes, off: int): + def _add_node_announcement(self, rec: bytes, off: int): fields = node_announcement.read(io.BytesIO(rec[2:]), {}) node_id = GossmapNodeId(fields['node_id']) self.nodes[node_id].announce_fields = fields @@ -230,7 +230,7 @@ def reopen_store(self): """FIXME: Implement!""" assert False - def remove_channel_by_deletemsg(self, rec: bytes): + def _remove_channel_by_deletemsg(self, rec: bytes): scid, = struct.unpack(">Q", rec[2:]) # It might have already been deleted when we skipped it. if scid in self.channels: @@ -272,19 +272,19 @@ def refresh(self): rectype, = struct.unpack(">H", rec[:2]) if rectype == channel_announcement.number: - self.add_channel(rec, off, False) + self._add_channel(rec, off, False) elif rectype == WIRE_GOSSIP_STORE_PRIVATE_CHANNEL: - self.add_channel(rec[2 + 8 + 2:], off + 2 + 8 + 2, True) + self._add_channel(rec[2 + 8 + 2:], off + 2 + 8 + 2, True) elif rectype == gossip_store_channel_amount.number: self._set_channel_amount(rec) elif rectype == channel_update.number: - self.update_channel(rec, off) + self._update_channel(rec, off) elif rectype == WIRE_GOSSIP_STORE_PRIVATE_UPDATE: - self.update_channel(rec[2 + 2:], off + 2 + 2) + self._update_channel(rec[2 + 2:], off + 2 + 2) elif rectype == WIRE_GOSSIP_STORE_DELETE_CHAN: - self.remove_channel_by_deletemsg(rec) + self._remove_channel_by_deletemsg(rec) elif rectype == node_announcement.number: - self.add_node_announcement(rec, off) + self._add_node_announcement(rec, off) elif rectype == WIRE_GOSSIP_STORE_ENDED: self.reopen_store() else: