From 96c9a483d0bed5e7ec054d9cea8c663ab3141855 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Tue, 17 Nov 2020 07:51:45 +0100 Subject: [PATCH] lnrater: follow-up Add comment on node score and return copies of channel db dicts. --- electrum/channel_db.py | 4 ++-- electrum/lnrater.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/electrum/channel_db.py b/electrum/channel_db.py index 38a31258a..a1c9f67f0 100644 --- a/electrum/channel_db.py +++ b/electrum/channel_db.py @@ -762,11 +762,11 @@ class ChannelDB(SqlDB): def get_node_infos(self) -> Dict[bytes, NodeInfo]: with self.lock: - return self._nodes + return self._nodes.copy() def get_node_policies(self) -> Dict[Tuple[bytes, ShortChannelID], Policy]: with self.lock: - return self._policies + return self._policies.copy() def to_dict(self) -> dict: """ Generates a graph representation in terms of a dictionary. diff --git a/electrum/lnrater.py b/electrum/lnrater.py index 0863a95cb..f84559183 100644 --- a/electrum/lnrater.py +++ b/electrum/lnrater.py @@ -214,9 +214,11 @@ class LNRater(Logger): heuristics = [] heuristics_weights = [] - # example of how we could construct a scalar score for nodes - # this is probably not what we want to to, this is roughly - # preferential attachment + # Construct an average score which leads to recommendation of nodes + # with low fees, large capacity and reasonable number of channels. + # This is somewhat akin to preferential attachment, but low fee + # nodes are more favored. Here we make a compromise between user + # comfort and decentralization, tending towards user comfort. # number of channels heuristics.append(stats.number_channels / max_num_chan)