aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discv5/node.go
diff options
context:
space:
mode:
Diffstat (limited to 'p2p/discv5/node.go')
-rw-r--r--p2p/discv5/node.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/p2p/discv5/node.go b/p2p/discv5/node.go
index c99b4da14..2db7a508f 100644
--- a/p2p/discv5/node.go
+++ b/p2p/discv5/node.go
@@ -215,6 +215,20 @@ func MustParseNode(rawurl string) *Node {
return n
}
+// MarshalText implements encoding.TextMarshaler.
+func (n *Node) MarshalText() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// UnmarshalText implements encoding.TextUnmarshaler.
+func (n *Node) UnmarshalText(text []byte) error {
+ dec, err := ParseNode(string(text))
+ if err == nil {
+ *n = *dec
+ }
+ return err
+}
+
// type nodeQueue []*Node
//
// // pushNew adds n to the end if it is not present.