Add serde support for NodeRecord primitive type (#617)

* Add serde support to NodeRecord

* Move NodeRecord to primitives

along with NodeKey and Octets

* Reexport NodeRecord from discv4

* Move NodeKey and kad_key back to discv4::node

Also, move NodeRecord::key functionality to a helper function: discv4::node::record_key.
This avoids the discv5 dependency in the primitives crate.

* Fix NodeRecord (de)serializing

The default derive macros work with a dictionary like display.
Changed that to serde_with macros, that use Display and FromStr traits.

* Add some tests for NodeRecord (de)serializing

* Hide NodeKey struct

* Move Octets after NodeRecord

* Replace record_key with From trait

* Fix clippy error

unnecessary into()
This commit is contained in:
Tomás
2022-12-27 14:03:54 -03:00
committed by GitHub
parent c2b19cecef
commit dcd3923d19
14 changed files with 526 additions and 339 deletions

View File

@ -31,13 +31,12 @@ tokio-stream = "0.1"
# misc
bytes = "1.2"
generic-array = "0.14"
tracing = "0.1"
thiserror = "1.0"
url = "2.3"
hex = "0.4"
public-ip = "0.2"
rand = { version = "0.8", optional = true }
generic-array = "0.14"
[dev-dependencies]
rand = "0.8"
@ -45,4 +44,4 @@ tokio = { version = "1", features = ["full"] }
reth-tracing = { path = "../../tracing" }
[features]
mock = ["rand"]
mock = ["rand"]