mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 03:01:52 +01:00
tlv: generate types for the custom message range
We generate the first 100 custom messages. For anything beyond this, a custom struct can be created.
This commit is contained in:
parent
1bac89dda7
commit
bdfd79425b
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
numberOfTypes = 100
|
numberOfTypes = 100
|
||||||
|
customTypeStart = 65536
|
||||||
defaultOutputFile = "tlv_types_generated.go"
|
defaultOutputFile = "tlv_types_generated.go"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,9 +33,18 @@ type TlvType{{ $index }} = *tlvType{{ $index }}
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Create a slice of items that the template can range over.
|
// Create a slice of items that the template can range over.
|
||||||
var items []struct{}
|
//
|
||||||
for i := uint16(0); i <= numberOfTypes; i++ {
|
// We'll generate 100 elements from the lower end of the TLV range
|
||||||
items = append(items, struct{}{})
|
// first.
|
||||||
|
items := make(map[uint32]struct{})
|
||||||
|
for i := uint32(0); i <= numberOfTypes; i++ {
|
||||||
|
items[i] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// With the lower end generated, we'll now generate 100 records in the
|
||||||
|
// upper end of the range.
|
||||||
|
for i := uint32(customTypeStart); i <= customTypeStart+numberOfTypes; i++ {
|
||||||
|
items[i] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
tpl, err := template.New("tlv").Parse(typeCodeTemplate)
|
tpl, err := template.New("tlv").Parse(typeCodeTemplate)
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user