mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
Merge pull request #8748 from guggero/custom-tlv-types
tlv: generate TLV types for custom ranges
This commit is contained in:
commit
9d358bc649
@ -8,8 +8,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
numberOfTypes = 100
|
||||
defaultOutputFile = "tlv_types_generated.go"
|
||||
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"
|
||||
)
|
||||
|
||||
const typeCodeTemplate = `// Code generated by tlv/internal/gen; DO NOT EDIT.
|
||||
@ -32,9 +36,18 @@ type TlvType{{ $index }} = *tlvType{{ $index }}
|
||||
|
||||
func main() {
|
||||
// Create a slice of items that the template can range over.
|
||||
var items []struct{}
|
||||
for i := uint16(0); i <= numberOfTypes; i++ {
|
||||
items = append(items, struct{}{})
|
||||
//
|
||||
// We'll generate 100 elements from the lower end of the TLV range
|
||||
// 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)
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user