p2p/dnsdisc: add implementation of EIP-1459 (#20094)
This adds an implementation of node discovery via DNS TXT records to the go-ethereum library. The implementation doesn't match EIP-1459 exactly, the main difference being that this implementation uses separate merkle trees for tree links and ENRs. The EIP will be updated to match p2p/dnsdisc. To maintain DNS trees, cmd/devp2p provides a frontend for the p2p/dnsdisc library. The new 'dns' subcommands can be used to create, sign and deploy DNS discovery trees.
This commit is contained in:
40
vendor/github.com/cloudflare/cloudflare-go/duration.go
generated
vendored
Normal file
40
vendor/github.com/cloudflare/cloudflare-go/duration.go
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
package cloudflare
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Duration implements json.Marshaler and json.Unmarshaler for time.Duration
|
||||
// using the fmt.Stringer interface of time.Duration and time.ParseDuration.
|
||||
type Duration struct {
|
||||
time.Duration
|
||||
}
|
||||
|
||||
// MarshalJSON encodes a Duration as a JSON string formatted using String.
|
||||
func (d Duration) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(d.Duration.String())
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes a Duration from a JSON string parsed using time.ParseDuration.
|
||||
func (d *Duration) UnmarshalJSON(buf []byte) error {
|
||||
var str string
|
||||
|
||||
err := json.Unmarshal(buf, &str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dur, err := time.ParseDuration(str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.Duration = dur
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
_ = json.Marshaler((*Duration)(nil))
|
||||
_ = json.Unmarshaler((*Duration)(nil))
|
||||
)
|
Reference in New Issue
Block a user