MCPcopy Create free account
hub / github.com/ElementsProject/lightning / _ser_varint

Function _ser_varint

tests/test_opening.py:67–74  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

65
66
67def _ser_varint(n):
68 if n < 0xfd:
69 return bytes([n])
70 elif n <= 0xffff:
71 return b'\xfd' + n.to_bytes(2, 'little')
72 elif n <= 0xffffffff:
73 return b'\xfe' + n.to_bytes(4, 'little')
74 return b'\xff' + n.to_bytes(8, 'little')
75
76
77def _ser_bytes(b):

Callers 2

_ser_bytesFunction · 0.85

Calls 1

to_bytesMethod · 0.45

Tested by

no test coverage detected