mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
config/spec: preserve nanosecond Duration wire format for v2
ConfigSpec.JSON() exports the flag specification as JSON. Duration-typed default values (e.g. consensus timeouts) need to render as integer nanoseconds for v1-compatible consumers and so the embedded JSON fixtures roundtrip. Pass jsonv1.FormatDurationAsNano(true) at the Marshal site.
This commit is contained in:
+2
-1
@@ -8,6 +8,7 @@ package spec
|
||||
|
||||
import (
|
||||
"github.com/go-json-experiment/json"
|
||||
jsonv1 "github.com/go-json-experiment/json/v1"
|
||||
"github.com/go-json-experiment/json/jsontext"
|
||||
"time"
|
||||
)
|
||||
@@ -208,7 +209,7 @@ func (s *ConfigSpec) DeprecatedFlags() []FlagSpec {
|
||||
|
||||
// JSON returns the spec as formatted JSON.
|
||||
func (s *ConfigSpec) JSON() ([]byte, error) {
|
||||
return json.Marshal(s, jsontext.WithIndent(" "))
|
||||
return json.Marshal(s, jsontext.WithIndent(" "), jsonv1.FormatDurationAsNano(true))
|
||||
}
|
||||
|
||||
// ValidateValue checks if a value is valid for a flag.
|
||||
|
||||
Reference in New Issue
Block a user