mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 12:30:07 +00:00
move lnworker.first_block to constants
This commit is contained in:
parent
a0764c017c
commit
6d8c605307
3 changed files with 11 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue