tlv: add MakeBigSizeRecord to save space

This commit adds a pair of encoder/decoder to take the advantage of the
BigSize format when encoding an uint64 and possibly an uint32.

Often the time an uint64 value is not big enough to fill all the 8
bytes, thus using BigSize can save extra bytes when save it to db. And
for uint32, if we know most of the values do not exceed 65536, we can
also save at least 1 byte using BigSize format.

This commit introduces `MakeBigSizeRecord` that can be used optionally
where db space is a concern.
This commit is contained in:
yyforyongyu committed 2022-04-16 12:05:23 +08:00
1 parent 02d17bb81a
commit 4ddb5c586b
4 files changed
+257

No files matched your search

@@ -175,6 +175,9 @@ then watch it on chain. Taproot script spends are also supported through the
* [Announce the keysend feature bit in NodeAnnouncement if `--accept-keysend`
is set](https://github.com/lightningnetwork/lnd/pull/6414)
* [Add a new method in `tlv` to encode an uint64/uint32 field using `BigSize`
format.](https://github.com/lightningnetwork/lnd/pull/6421)
## RPC Server
* [Add value to the field