pyln-proto: Add compactsize alias for varint_{encode,decode}

We were mistakenly calling it varint, while Bitcoin refers to it as
CompactSize.
This commit is contained in:
Christian Decker 2020-10-15 10:23:02 +02:00 committed by Rusty Russell
parent 895722fd8a
commit 9a0327cd25

View file

@ -2,7 +2,7 @@ import coincurve
import struct import struct
def varint_encode(i, w): def compactsize_encode(i, w):
"""Encode an integer `i` into the writer `w` """Encode an integer `i` into the writer `w`
""" """
if i < 0xFD: if i < 0xFD:
@ -15,7 +15,7 @@ def varint_encode(i, w):
w.write(struct.pack("!BQ", 0xFF, i)) w.write(struct.pack("!BQ", 0xFF, i))
def varint_decode(r): def compactsize_decode(r):
"""Decode an integer from reader `r` """Decode an integer from reader `r`
""" """
raw = r.read(1) raw = r.read(1)
@ -33,6 +33,14 @@ def varint_decode(r):
return struct.unpack("!Q", r.read(8))[0] return struct.unpack("!Q", r.read(8))[0]
def varint_encode(i, w):
return compactsize_encode(i, w)
def varint_decode(r):
return compactsize_decode(r)
class ShortChannelId(object): class ShortChannelId(object):
def __init__(self, block, txnum, outnum): def __init__(self, block, txnum, outnum):
self.block = block self.block = block