mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-21 06:06:20 +02:00
tlv: generate TLV types for custom ranges
This commit is contained in:
@@ -8,7 +8,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
numberOfTypes = 100
|
numberOfTypes uint32 = 100
|
||||||
|
|
||||||
|
// customTypeStart defines the beginning of the custom TLV type range as
|
||||||
|
// defined in BOLT-01.
|
||||||
|
customTypeStart uint32 = 65536
|
||||||
defaultOutputFile = "tlv_types_generated.go"
|
defaultOutputFile = "tlv_types_generated.go"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -32,9 +36,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 := 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
Reference in New Issue
Block a user