Skip to content

Commit

Permalink
fixup! BOLT01: add wire TLV proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
cfromknecht committed May 16, 2019
1 parent 2ab62c6 commit e1e8ada
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion 01-messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,16 @@ field, the node is forced to add parsing logic for that field in order to
determine the offset of any fields that follow.

The monotonicity constraint ensures that all `type`s are unique and can appear
at most once.
at most once. Fields that need which to have multiple occurrences of some
primitive type or object, e.g. vectors or maps, may do so by defining the
encoding such that they are all serialized within a single `tlv_record`. The
uniqueness constraint, among other things, enables the following optimizations:
- canonical ordering is defined independent of the encoded `value`s.
- canonical ordering can be known at compile-time, rather that being determined
dynamically at the time of encoding.
- verifying canonical ordering requires less state and is cheaper.
- variable-size fields can reserve their expected size up front, rather than
appending elements sequentially and incurring double-and-copy overhead.

The use of a varint for `length` permits a space savings over a fixed 16-bit
`length` for `value`s whose encoded length is less than 253 bytes. When
Expand Down

0 comments on commit e1e8ada

Please sign in to comment.