Replying to Avatar Loki

Anyone familiar with the LND codebase and the TLV encoding library in it would probably be vaguely familiar with the following two functions:

func ReadVarInt(r io.Reader, buf *[8]byte) (uint64, error)

func WriteVarInt(w io.Writer, val uint64, buf *[8]byte) error

found here:

https://github.com/lightningnetwork/lnd/blob/master/tlv/varint.go

Note how this is the same function signatures as these also:

func EUint64T(w io.Writer, val uint64, buf *[8]byte) error

func DUint8(r io.Reader, val interface{}, buf *[8]byte, l uint64) error

oh, look at that. This first one above is different. The others are not though:

func EBytes32(w io.Writer, val interface{}, _ *[8]byte) error

func DBytes32(r io.Reader, val interface{}, _ *[8]byte, l uint64) error

Definitely should be an interface. WTH @roasbeef (he's not here???)

...ah yes, ok, there is two forms of the encode.

and yes, also, the types and naming don't conform with how it would be done as an interface.

But this thing is such a small library, maybe I should just fork it, and eliminate the variants and make them all `val interface{}`...

Reply to this note

Please Login to reply.

Discussion

No replies yet.