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

@ -2,8 +2,8 @@
use crate::error::NetworkError;
use futures::StreamExt;
use reth_discv4::{DiscoveryUpdate, Discv4, Discv4Config, NodeRecord};
use reth_primitives::{ForkId, PeerId};
use reth_discv4::{DiscoveryUpdate, Discv4, Discv4Config};
use reth_primitives::{ForkId, NodeRecord, PeerId};
use secp256k1::SecretKey;
use std::{
collections::{hash_map::Entry, HashMap, VecDeque},