mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
tlv: generate types for gossip unsigned range
For pure TLV messages such as Gossip 1.75 and Bolt12 messages, there are defined TLV ranges for unsigned data vs signed data. The signed ranges are the inclusive ranges of 0 to 159 and 1000000000 to 2999999999. What we do here in this commit is: 1) update the number of main types generated so that they include type 160 which is the first type in the un-signed range and we will make use of this type for signature fields in gossip messages. Next, we add two marker types so that we can define the rest of the ranges.
This commit is contained in:
parent
136cb42457
commit
63d5e92af1
@ -8,14 +8,29 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
numberOfTypes uint32 = 100
|
||||
numberOfTypes uint32 = 300
|
||||
|
||||
// customTypeStart defines the beginning of the custom TLV type range as
|
||||
// defined in BOLT-01.
|
||||
customTypeStart uint32 = 65536
|
||||
defaultOutputFile = "tlv_types_generated.go"
|
||||
customTypeStart uint32 = 65536
|
||||
|
||||
// pureTLVSecondSignedTypeRangeStart defines the first TLV type of the
|
||||
// second defined signed TLV range used in pure TLV messages.
|
||||
pureTLVSecondSignedTypeRangeStart uint32 = 1000000000
|
||||
|
||||
// pureTLVSecondUnsignedTypeRangeStart defines the first TLV type of the
|
||||
// second defined unsigned TLV range used in pure TLV messages.
|
||||
pureTLVSecondUnsignedTypeRangeStart uint32 = 3000000000
|
||||
|
||||
defaultOutputFile = "tlv_types_generated.go"
|
||||
)
|
||||
|
||||
// typeMarkers defines any adhoc TLV types we want to generate.
|
||||
var typeMarkers = map[uint32]struct{}{
|
||||
pureTLVSecondSignedTypeRangeStart: {},
|
||||
pureTLVSecondUnsignedTypeRangeStart: {},
|
||||
}
|
||||
|
||||
const typeCodeTemplate = `// Code generated by tlv/internal/gen; DO NOT EDIT.
|
||||
|
||||
package tlv
|
||||
@ -50,6 +65,11 @@ func main() {
|
||||
items[i] = struct{}{}
|
||||
}
|
||||
|
||||
// We'll also generate any marker types.
|
||||
for t := range typeMarkers {
|
||||
items[t] = struct{}{}
|
||||
}
|
||||
|
||||
tpl, err := template.New("tlv").Parse(typeCodeTemplate)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user