electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 0acd0c23d32f43bb91c29cf7e8d1288d40d8cc74
parent d30307b29e83ec2b0b08940c511d3681c8d2d0f5
Author: ThomasV <thomasv@electrum.org>
Date:   Sat, 18 May 2019 13:15:42 +0200

fix: key must be unique (sql)

Diffstat:
Melectrum/lnrouter.py | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/electrum/lnrouter.py b/electrum/lnrouter.py @@ -373,7 +373,7 @@ class ChannelDB(SqlDB): orphaned = [] # no channel announcement for channel update expired = [] # update older than two weeks deprecated = [] # update older than database entry - good = [] # good updates + good = {} # good updates to_delete = [] # database entries to delete # filter orphaned and expired first known = [] @@ -398,17 +398,19 @@ class ChannelDB(SqlDB): old_policies = self.get_policies_for_updates(known) for payload in known: timestamp = int.from_bytes(payload['timestamp'], "big") - start_node = payload['start_node'].hex() - short_channel_id = payload['short_channel_id'].hex() - old_policy = old_policies.get(short_channel_id+start_node) + start_node = payload['start_node'] + short_channel_id = payload['short_channel_id'] + key = (short_channel_id+start_node).hex() + old_policy = old_policies.get(key) if old_policy: if timestamp <= old_policy.timestamp: deprecated.append(short_channel_id) else: - good.append(payload) + good[key] = payload to_delete.append(old_policy) else: - good.append(payload) + good[key] = payload + good = list(good.values()) return orphaned, expired, deprecated, good, to_delete def add_channel_update(self, payload):