From 454f56d4a849aad278937846ed94cd8644becf79 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 13 May 2024 16:44:39 +0200 Subject: [PATCH] tlv: generate TLV types for custom ranges --- tlv/internal/gen/gen_tlv_types.go | 23 +- tlv/tlv_types_generated.go | 1010 +++++++++++++++++++++++++++++ 2 files changed, 1028 insertions(+), 5 deletions(-) diff --git a/tlv/internal/gen/gen_tlv_types.go b/tlv/internal/gen/gen_tlv_types.go index da2d4572e2..331d10b646 100644 --- a/tlv/internal/gen/gen_tlv_types.go +++ b/tlv/internal/gen/gen_tlv_types.go @@ -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) diff --git a/tlv/tlv_types_generated.go b/tlv/tlv_types_generated.go index f2e0420fdf..c75a86232b 100644 --- a/tlv/tlv_types_generated.go +++ b/tlv/tlv_types_generated.go @@ -1011,3 +1011,1013 @@ func (t *tlvType100) TypeVal() Type { func (t *tlvType100) tlv() {} type TlvType100 = *tlvType100 + +type tlvType65536 struct{} + +func (t *tlvType65536) TypeVal() Type { + return 65536 +} + +func (t *tlvType65536) tlv() {} + +type TlvType65536 = *tlvType65536 + +type tlvType65537 struct{} + +func (t *tlvType65537) TypeVal() Type { + return 65537 +} + +func (t *tlvType65537) tlv() {} + +type TlvType65537 = *tlvType65537 + +type tlvType65538 struct{} + +func (t *tlvType65538) TypeVal() Type { + return 65538 +} + +func (t *tlvType65538) tlv() {} + +type TlvType65538 = *tlvType65538 + +type tlvType65539 struct{} + +func (t *tlvType65539) TypeVal() Type { + return 65539 +} + +func (t *tlvType65539) tlv() {} + +type TlvType65539 = *tlvType65539 + +type tlvType65540 struct{} + +func (t *tlvType65540) TypeVal() Type { + return 65540 +} + +func (t *tlvType65540) tlv() {} + +type TlvType65540 = *tlvType65540 + +type tlvType65541 struct{} + +func (t *tlvType65541) TypeVal() Type { + return 65541 +} + +func (t *tlvType65541) tlv() {} + +type TlvType65541 = *tlvType65541 + +type tlvType65542 struct{} + +func (t *tlvType65542) TypeVal() Type { + return 65542 +} + +func (t *tlvType65542) tlv() {} + +type TlvType65542 = *tlvType65542 + +type tlvType65543 struct{} + +func (t *tlvType65543) TypeVal() Type { + return 65543 +} + +func (t *tlvType65543) tlv() {} + +type TlvType65543 = *tlvType65543 + +type tlvType65544 struct{} + +func (t *tlvType65544) TypeVal() Type { + return 65544 +} + +func (t *tlvType65544) tlv() {} + +type TlvType65544 = *tlvType65544 + +type tlvType65545 struct{} + +func (t *tlvType65545) TypeVal() Type { + return 65545 +} + +func (t *tlvType65545) tlv() {} + +type TlvType65545 = *tlvType65545 + +type tlvType65546 struct{} + +func (t *tlvType65546) TypeVal() Type { + return 65546 +} + +func (t *tlvType65546) tlv() {} + +type TlvType65546 = *tlvType65546 + +type tlvType65547 struct{} + +func (t *tlvType65547) TypeVal() Type { + return 65547 +} + +func (t *tlvType65547) tlv() {} + +type TlvType65547 = *tlvType65547 + +type tlvType65548 struct{} + +func (t *tlvType65548) TypeVal() Type { + return 65548 +} + +func (t *tlvType65548) tlv() {} + +type TlvType65548 = *tlvType65548 + +type tlvType65549 struct{} + +func (t *tlvType65549) TypeVal() Type { + return 65549 +} + +func (t *tlvType65549) tlv() {} + +type TlvType65549 = *tlvType65549 + +type tlvType65550 struct{} + +func (t *tlvType65550) TypeVal() Type { + return 65550 +} + +func (t *tlvType65550) tlv() {} + +type TlvType65550 = *tlvType65550 + +type tlvType65551 struct{} + +func (t *tlvType65551) TypeVal() Type { + return 65551 +} + +func (t *tlvType65551) tlv() {} + +type TlvType65551 = *tlvType65551 + +type tlvType65552 struct{} + +func (t *tlvType65552) TypeVal() Type { + return 65552 +} + +func (t *tlvType65552) tlv() {} + +type TlvType65552 = *tlvType65552 + +type tlvType65553 struct{} + +func (t *tlvType65553) TypeVal() Type { + return 65553 +} + +func (t *tlvType65553) tlv() {} + +type TlvType65553 = *tlvType65553 + +type tlvType65554 struct{} + +func (t *tlvType65554) TypeVal() Type { + return 65554 +} + +func (t *tlvType65554) tlv() {} + +type TlvType65554 = *tlvType65554 + +type tlvType65555 struct{} + +func (t *tlvType65555) TypeVal() Type { + return 65555 +} + +func (t *tlvType65555) tlv() {} + +type TlvType65555 = *tlvType65555 + +type tlvType65556 struct{} + +func (t *tlvType65556) TypeVal() Type { + return 65556 +} + +func (t *tlvType65556) tlv() {} + +type TlvType65556 = *tlvType65556 + +type tlvType65557 struct{} + +func (t *tlvType65557) TypeVal() Type { + return 65557 +} + +func (t *tlvType65557) tlv() {} + +type TlvType65557 = *tlvType65557 + +type tlvType65558 struct{} + +func (t *tlvType65558) TypeVal() Type { + return 65558 +} + +func (t *tlvType65558) tlv() {} + +type TlvType65558 = *tlvType65558 + +type tlvType65559 struct{} + +func (t *tlvType65559) TypeVal() Type { + return 65559 +} + +func (t *tlvType65559) tlv() {} + +type TlvType65559 = *tlvType65559 + +type tlvType65560 struct{} + +func (t *tlvType65560) TypeVal() Type { + return 65560 +} + +func (t *tlvType65560) tlv() {} + +type TlvType65560 = *tlvType65560 + +type tlvType65561 struct{} + +func (t *tlvType65561) TypeVal() Type { + return 65561 +} + +func (t *tlvType65561) tlv() {} + +type TlvType65561 = *tlvType65561 + +type tlvType65562 struct{} + +func (t *tlvType65562) TypeVal() Type { + return 65562 +} + +func (t *tlvType65562) tlv() {} + +type TlvType65562 = *tlvType65562 + +type tlvType65563 struct{} + +func (t *tlvType65563) TypeVal() Type { + return 65563 +} + +func (t *tlvType65563) tlv() {} + +type TlvType65563 = *tlvType65563 + +type tlvType65564 struct{} + +func (t *tlvType65564) TypeVal() Type { + return 65564 +} + +func (t *tlvType65564) tlv() {} + +type TlvType65564 = *tlvType65564 + +type tlvType65565 struct{} + +func (t *tlvType65565) TypeVal() Type { + return 65565 +} + +func (t *tlvType65565) tlv() {} + +type TlvType65565 = *tlvType65565 + +type tlvType65566 struct{} + +func (t *tlvType65566) TypeVal() Type { + return 65566 +} + +func (t *tlvType65566) tlv() {} + +type TlvType65566 = *tlvType65566 + +type tlvType65567 struct{} + +func (t *tlvType65567) TypeVal() Type { + return 65567 +} + +func (t *tlvType65567) tlv() {} + +type TlvType65567 = *tlvType65567 + +type tlvType65568 struct{} + +func (t *tlvType65568) TypeVal() Type { + return 65568 +} + +func (t *tlvType65568) tlv() {} + +type TlvType65568 = *tlvType65568 + +type tlvType65569 struct{} + +func (t *tlvType65569) TypeVal() Type { + return 65569 +} + +func (t *tlvType65569) tlv() {} + +type TlvType65569 = *tlvType65569 + +type tlvType65570 struct{} + +func (t *tlvType65570) TypeVal() Type { + return 65570 +} + +func (t *tlvType65570) tlv() {} + +type TlvType65570 = *tlvType65570 + +type tlvType65571 struct{} + +func (t *tlvType65571) TypeVal() Type { + return 65571 +} + +func (t *tlvType65571) tlv() {} + +type TlvType65571 = *tlvType65571 + +type tlvType65572 struct{} + +func (t *tlvType65572) TypeVal() Type { + return 65572 +} + +func (t *tlvType65572) tlv() {} + +type TlvType65572 = *tlvType65572 + +type tlvType65573 struct{} + +func (t *tlvType65573) TypeVal() Type { + return 65573 +} + +func (t *tlvType65573) tlv() {} + +type TlvType65573 = *tlvType65573 + +type tlvType65574 struct{} + +func (t *tlvType65574) TypeVal() Type { + return 65574 +} + +func (t *tlvType65574) tlv() {} + +type TlvType65574 = *tlvType65574 + +type tlvType65575 struct{} + +func (t *tlvType65575) TypeVal() Type { + return 65575 +} + +func (t *tlvType65575) tlv() {} + +type TlvType65575 = *tlvType65575 + +type tlvType65576 struct{} + +func (t *tlvType65576) TypeVal() Type { + return 65576 +} + +func (t *tlvType65576) tlv() {} + +type TlvType65576 = *tlvType65576 + +type tlvType65577 struct{} + +func (t *tlvType65577) TypeVal() Type { + return 65577 +} + +func (t *tlvType65577) tlv() {} + +type TlvType65577 = *tlvType65577 + +type tlvType65578 struct{} + +func (t *tlvType65578) TypeVal() Type { + return 65578 +} + +func (t *tlvType65578) tlv() {} + +type TlvType65578 = *tlvType65578 + +type tlvType65579 struct{} + +func (t *tlvType65579) TypeVal() Type { + return 65579 +} + +func (t *tlvType65579) tlv() {} + +type TlvType65579 = *tlvType65579 + +type tlvType65580 struct{} + +func (t *tlvType65580) TypeVal() Type { + return 65580 +} + +func (t *tlvType65580) tlv() {} + +type TlvType65580 = *tlvType65580 + +type tlvType65581 struct{} + +func (t *tlvType65581) TypeVal() Type { + return 65581 +} + +func (t *tlvType65581) tlv() {} + +type TlvType65581 = *tlvType65581 + +type tlvType65582 struct{} + +func (t *tlvType65582) TypeVal() Type { + return 65582 +} + +func (t *tlvType65582) tlv() {} + +type TlvType65582 = *tlvType65582 + +type tlvType65583 struct{} + +func (t *tlvType65583) TypeVal() Type { + return 65583 +} + +func (t *tlvType65583) tlv() {} + +type TlvType65583 = *tlvType65583 + +type tlvType65584 struct{} + +func (t *tlvType65584) TypeVal() Type { + return 65584 +} + +func (t *tlvType65584) tlv() {} + +type TlvType65584 = *tlvType65584 + +type tlvType65585 struct{} + +func (t *tlvType65585) TypeVal() Type { + return 65585 +} + +func (t *tlvType65585) tlv() {} + +type TlvType65585 = *tlvType65585 + +type tlvType65586 struct{} + +func (t *tlvType65586) TypeVal() Type { + return 65586 +} + +func (t *tlvType65586) tlv() {} + +type TlvType65586 = *tlvType65586 + +type tlvType65587 struct{} + +func (t *tlvType65587) TypeVal() Type { + return 65587 +} + +func (t *tlvType65587) tlv() {} + +type TlvType65587 = *tlvType65587 + +type tlvType65588 struct{} + +func (t *tlvType65588) TypeVal() Type { + return 65588 +} + +func (t *tlvType65588) tlv() {} + +type TlvType65588 = *tlvType65588 + +type tlvType65589 struct{} + +func (t *tlvType65589) TypeVal() Type { + return 65589 +} + +func (t *tlvType65589) tlv() {} + +type TlvType65589 = *tlvType65589 + +type tlvType65590 struct{} + +func (t *tlvType65590) TypeVal() Type { + return 65590 +} + +func (t *tlvType65590) tlv() {} + +type TlvType65590 = *tlvType65590 + +type tlvType65591 struct{} + +func (t *tlvType65591) TypeVal() Type { + return 65591 +} + +func (t *tlvType65591) tlv() {} + +type TlvType65591 = *tlvType65591 + +type tlvType65592 struct{} + +func (t *tlvType65592) TypeVal() Type { + return 65592 +} + +func (t *tlvType65592) tlv() {} + +type TlvType65592 = *tlvType65592 + +type tlvType65593 struct{} + +func (t *tlvType65593) TypeVal() Type { + return 65593 +} + +func (t *tlvType65593) tlv() {} + +type TlvType65593 = *tlvType65593 + +type tlvType65594 struct{} + +func (t *tlvType65594) TypeVal() Type { + return 65594 +} + +func (t *tlvType65594) tlv() {} + +type TlvType65594 = *tlvType65594 + +type tlvType65595 struct{} + +func (t *tlvType65595) TypeVal() Type { + return 65595 +} + +func (t *tlvType65595) tlv() {} + +type TlvType65595 = *tlvType65595 + +type tlvType65596 struct{} + +func (t *tlvType65596) TypeVal() Type { + return 65596 +} + +func (t *tlvType65596) tlv() {} + +type TlvType65596 = *tlvType65596 + +type tlvType65597 struct{} + +func (t *tlvType65597) TypeVal() Type { + return 65597 +} + +func (t *tlvType65597) tlv() {} + +type TlvType65597 = *tlvType65597 + +type tlvType65598 struct{} + +func (t *tlvType65598) TypeVal() Type { + return 65598 +} + +func (t *tlvType65598) tlv() {} + +type TlvType65598 = *tlvType65598 + +type tlvType65599 struct{} + +func (t *tlvType65599) TypeVal() Type { + return 65599 +} + +func (t *tlvType65599) tlv() {} + +type TlvType65599 = *tlvType65599 + +type tlvType65600 struct{} + +func (t *tlvType65600) TypeVal() Type { + return 65600 +} + +func (t *tlvType65600) tlv() {} + +type TlvType65600 = *tlvType65600 + +type tlvType65601 struct{} + +func (t *tlvType65601) TypeVal() Type { + return 65601 +} + +func (t *tlvType65601) tlv() {} + +type TlvType65601 = *tlvType65601 + +type tlvType65602 struct{} + +func (t *tlvType65602) TypeVal() Type { + return 65602 +} + +func (t *tlvType65602) tlv() {} + +type TlvType65602 = *tlvType65602 + +type tlvType65603 struct{} + +func (t *tlvType65603) TypeVal() Type { + return 65603 +} + +func (t *tlvType65603) tlv() {} + +type TlvType65603 = *tlvType65603 + +type tlvType65604 struct{} + +func (t *tlvType65604) TypeVal() Type { + return 65604 +} + +func (t *tlvType65604) tlv() {} + +type TlvType65604 = *tlvType65604 + +type tlvType65605 struct{} + +func (t *tlvType65605) TypeVal() Type { + return 65605 +} + +func (t *tlvType65605) tlv() {} + +type TlvType65605 = *tlvType65605 + +type tlvType65606 struct{} + +func (t *tlvType65606) TypeVal() Type { + return 65606 +} + +func (t *tlvType65606) tlv() {} + +type TlvType65606 = *tlvType65606 + +type tlvType65607 struct{} + +func (t *tlvType65607) TypeVal() Type { + return 65607 +} + +func (t *tlvType65607) tlv() {} + +type TlvType65607 = *tlvType65607 + +type tlvType65608 struct{} + +func (t *tlvType65608) TypeVal() Type { + return 65608 +} + +func (t *tlvType65608) tlv() {} + +type TlvType65608 = *tlvType65608 + +type tlvType65609 struct{} + +func (t *tlvType65609) TypeVal() Type { + return 65609 +} + +func (t *tlvType65609) tlv() {} + +type TlvType65609 = *tlvType65609 + +type tlvType65610 struct{} + +func (t *tlvType65610) TypeVal() Type { + return 65610 +} + +func (t *tlvType65610) tlv() {} + +type TlvType65610 = *tlvType65610 + +type tlvType65611 struct{} + +func (t *tlvType65611) TypeVal() Type { + return 65611 +} + +func (t *tlvType65611) tlv() {} + +type TlvType65611 = *tlvType65611 + +type tlvType65612 struct{} + +func (t *tlvType65612) TypeVal() Type { + return 65612 +} + +func (t *tlvType65612) tlv() {} + +type TlvType65612 = *tlvType65612 + +type tlvType65613 struct{} + +func (t *tlvType65613) TypeVal() Type { + return 65613 +} + +func (t *tlvType65613) tlv() {} + +type TlvType65613 = *tlvType65613 + +type tlvType65614 struct{} + +func (t *tlvType65614) TypeVal() Type { + return 65614 +} + +func (t *tlvType65614) tlv() {} + +type TlvType65614 = *tlvType65614 + +type tlvType65615 struct{} + +func (t *tlvType65615) TypeVal() Type { + return 65615 +} + +func (t *tlvType65615) tlv() {} + +type TlvType65615 = *tlvType65615 + +type tlvType65616 struct{} + +func (t *tlvType65616) TypeVal() Type { + return 65616 +} + +func (t *tlvType65616) tlv() {} + +type TlvType65616 = *tlvType65616 + +type tlvType65617 struct{} + +func (t *tlvType65617) TypeVal() Type { + return 65617 +} + +func (t *tlvType65617) tlv() {} + +type TlvType65617 = *tlvType65617 + +type tlvType65618 struct{} + +func (t *tlvType65618) TypeVal() Type { + return 65618 +} + +func (t *tlvType65618) tlv() {} + +type TlvType65618 = *tlvType65618 + +type tlvType65619 struct{} + +func (t *tlvType65619) TypeVal() Type { + return 65619 +} + +func (t *tlvType65619) tlv() {} + +type TlvType65619 = *tlvType65619 + +type tlvType65620 struct{} + +func (t *tlvType65620) TypeVal() Type { + return 65620 +} + +func (t *tlvType65620) tlv() {} + +type TlvType65620 = *tlvType65620 + +type tlvType65621 struct{} + +func (t *tlvType65621) TypeVal() Type { + return 65621 +} + +func (t *tlvType65621) tlv() {} + +type TlvType65621 = *tlvType65621 + +type tlvType65622 struct{} + +func (t *tlvType65622) TypeVal() Type { + return 65622 +} + +func (t *tlvType65622) tlv() {} + +type TlvType65622 = *tlvType65622 + +type tlvType65623 struct{} + +func (t *tlvType65623) TypeVal() Type { + return 65623 +} + +func (t *tlvType65623) tlv() {} + +type TlvType65623 = *tlvType65623 + +type tlvType65624 struct{} + +func (t *tlvType65624) TypeVal() Type { + return 65624 +} + +func (t *tlvType65624) tlv() {} + +type TlvType65624 = *tlvType65624 + +type tlvType65625 struct{} + +func (t *tlvType65625) TypeVal() Type { + return 65625 +} + +func (t *tlvType65625) tlv() {} + +type TlvType65625 = *tlvType65625 + +type tlvType65626 struct{} + +func (t *tlvType65626) TypeVal() Type { + return 65626 +} + +func (t *tlvType65626) tlv() {} + +type TlvType65626 = *tlvType65626 + +type tlvType65627 struct{} + +func (t *tlvType65627) TypeVal() Type { + return 65627 +} + +func (t *tlvType65627) tlv() {} + +type TlvType65627 = *tlvType65627 + +type tlvType65628 struct{} + +func (t *tlvType65628) TypeVal() Type { + return 65628 +} + +func (t *tlvType65628) tlv() {} + +type TlvType65628 = *tlvType65628 + +type tlvType65629 struct{} + +func (t *tlvType65629) TypeVal() Type { + return 65629 +} + +func (t *tlvType65629) tlv() {} + +type TlvType65629 = *tlvType65629 + +type tlvType65630 struct{} + +func (t *tlvType65630) TypeVal() Type { + return 65630 +} + +func (t *tlvType65630) tlv() {} + +type TlvType65630 = *tlvType65630 + +type tlvType65631 struct{} + +func (t *tlvType65631) TypeVal() Type { + return 65631 +} + +func (t *tlvType65631) tlv() {} + +type TlvType65631 = *tlvType65631 + +type tlvType65632 struct{} + +func (t *tlvType65632) TypeVal() Type { + return 65632 +} + +func (t *tlvType65632) tlv() {} + +type TlvType65632 = *tlvType65632 + +type tlvType65633 struct{} + +func (t *tlvType65633) TypeVal() Type { + return 65633 +} + +func (t *tlvType65633) tlv() {} + +type TlvType65633 = *tlvType65633 + +type tlvType65634 struct{} + +func (t *tlvType65634) TypeVal() Type { + return 65634 +} + +func (t *tlvType65634) tlv() {} + +type TlvType65634 = *tlvType65634 + +type tlvType65635 struct{} + +func (t *tlvType65635) TypeVal() Type { + return 65635 +} + +func (t *tlvType65635) tlv() {} + +type TlvType65635 = *tlvType65635 + +type tlvType65636 struct{} + +func (t *tlvType65636) TypeVal() Type { + return 65636 +} + +func (t *tlvType65636) tlv() {} + +type TlvType65636 = *tlvType65636