1
0

Merge pull request #10359 from f321x/lnpeer_remove_zlib_compression

lnpeer: remove zlib encoding support from gossip
This commit is contained in:
ThomasV
2025-12-13 11:18:22 +01:00
committed by GitHub
2 changed files with 45 additions and 7 deletions

View File

@@ -4,7 +4,6 @@
# Distributed under the MIT software license, see the accompanying
# file LICENCE or http://www.opensource.org/licenses/mit-license.php
import zlib
from collections import OrderedDict, defaultdict
import asyncio
import os
@@ -786,13 +785,13 @@ class Peer(Logger, EventListener):
first_blocknum=first_block,
number_of_blocks=num_blocks)
def decode_short_ids(self, encoded):
if encoded[0] == 0:
decoded = encoded[1:]
elif encoded[0] == 1:
decoded = zlib.decompress(encoded[1:])
else:
@staticmethod
def decode_short_ids(encoded):
if len(encoded) < 1 or (len(encoded) - 1) % 8 != 0:
raise Exception(f'decode_short_ids: invalid size: {len(encoded)=}')
elif encoded[0] != 0:
raise Exception(f'decode_short_ids: unexpected first byte: {encoded[0]}')
decoded = encoded[1:]
ids = [decoded[i:i+8] for i in range(0, len(decoded), 8)]
return ids