Skip to content

Commit

Permalink
pyln-client/gossmap: start internal function names with underscore _
Browse files Browse the repository at this point in the history
  • Loading branch information
m-schmoock committed Aug 26, 2021
1 parent ac3e0e5 commit 7d4527c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions contrib/pyln-client/pyln/client/gossmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'])
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 7d4527c

Please sign in to comment.