routerrpc+record: move custom set validation

This commit is contained in:
Joost Jager committed 2019-12-12 17:49:34 +01:00
1 parent 75b94dec2b
commit d16476e477
3 files changed
+26 -26

No files matched your search

+14
View File
@@ -1,5 +1,7 @@
package record
import "fmt"
const (
// CustomTypeStart is the start of the custom tlv type range as defined
// in BOLT 01.
@@ -8,3 +10,15 @@ const (
// CustomSet stores a set of custom key/value pairs.
type CustomSet map[uint64][]byte
// Validate checks that all custom records are in the custom type range.
func (c CustomSet) Validate() error {
for key := range c {
if key < CustomTypeStart {
return fmt.Errorf("no custom records with types "+
"below %v allowed", CustomTypeStart)
}
}
return nil
}