electrum

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

commit 6d8c6053078d3e6bdc16aeb00766dd0cb5e97ea0
parent a0764c017c01d6b13383465c6ccc5217b73ef773
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun, 26 May 2019 05:58:29 +0200

move lnworker.first_block to constants

Diffstat:
Melectrum/constants.py | 3+++
Melectrum/lnpeer.py | 16++++++++--------
Melectrum/lnworker.py | 2--
3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/electrum/constants.py b/electrum/constants.py @@ -46,6 +46,8 @@ GIT_REPO_ISSUES_URL = "https://github.com/spesmilo/electrum/issues" class AbstractNet: + BLOCK_HEIGHT_FIRST_LIGHTNING_CHANNELS = 0 + @classmethod def max_checkpoint(cls) -> int: return max(0, len(cls.CHECKPOINTS) * 2016 - 1) @@ -66,6 +68,7 @@ class BitcoinMainnet(AbstractNet): DEFAULT_PORTS = {'t': '50001', 's': '50002'} DEFAULT_SERVERS = read_json('servers.json', {}) CHECKPOINTS = read_json('checkpoints.json', []) + BLOCK_HEIGHT_FIRST_LIGHTNING_CHANNELS = 497000 XPRV_HEADERS = { 'standard': 0x0488ade4, # xprv diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py @@ -298,9 +298,9 @@ class Peer(Logger): await self.get_short_channel_ids(todo) async def get_channel_range(self): - req_index = self.lnworker.first_block - req_num = self.lnworker.network.get_local_height() - req_index - self.query_channel_range(req_index, req_num) + first_block = constants.net.BLOCK_HEIGHT_FIRST_LIGHTNING_CHANNELS + num_blocks = self.lnworker.network.get_local_height() - first_block + self.query_channel_range(first_block, num_blocks) intervals = [] ids = set() # note: implementations behave differently... @@ -333,7 +333,7 @@ class Peer(Logger): break if len(intervals) == 1 and complete: a, b = intervals[0] - if a <= req_index and b >= req_index + req_num: + if a <= first_block and b >= first_block + num_blocks: break return ids, complete @@ -348,13 +348,13 @@ class Peer(Logger): first_timestamp=timestamp, timestamp_range=b'\xff'*4) - def query_channel_range(self, index, num): - self.logger.info(f'query channel range {index} {num}') + def query_channel_range(self, first_block, num_blocks): + self.logger.info(f'query channel range {first_block} {num_blocks}') self.send_message( 'query_channel_range', chain_hash=constants.net.rev_genesis_bytes(), - first_blocknum=index, - number_of_blocks=num) + first_blocknum=first_block, + number_of_blocks=num_blocks) def encode_short_ids(self, ids): return chr(1) + zlib.compress(bfh(''.join(ids))) diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -229,8 +229,6 @@ class LNWorker(Logger): class LNGossip(LNWorker): - # height of first channel announcements - first_block = 497000 max_age = 14*24*3600 def __init__(self, network):