tlv+hop: contain odd/even logic in payload parsing

Tlv is used more widely in lnd than just for the onion payload. This
commit isolated the protocol-specific odd/even logic, so that tlv can be
used freely elsewhere. An example of this use is db serialization.
This commit is contained in:
Joost Jager
2019-11-10 12:06:49 +01:00
parent b222b6e625
commit 048971b40b
5 changed files with 66 additions and 136 deletions

View File

@@ -12,8 +12,9 @@ import (
// Type is an 64-bit identifier for a TLV Record.
type Type uint64
// TypeSet is an unordered set of Types.
type TypeSet map[Type]struct{}
// TypeSet is an unordered set of Types. The map item boolean values indicate
// whether the type that we parsed was known.
type TypeSet map[Type]bool
// Encoder is a signature for methods that can encode TLV values. An error
// should be returned if the Encoder cannot support the underlying type of val.