Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use NodeId instead of String for discv5 json types #1488

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

morph-dev
Copy link
Collaborator

@morph-dev morph-dev commented Sep 25, 2024

What was wrong?

We are using String to represent NodeId in json types.
I believe this isn't necessary as NodeId serialization is the same as what we are using (hex string prefixed with "0x").

This is not a big deal, but something I encounter while refactoring kbuckets.

How was it fixed?

Changed String to NodeId as type.

To-Do

@@ -24,15 +23,15 @@ pub struct KBucketsTable {
#[serde(rename_all = "camelCase")]
pub struct NodeInfo {
pub enr: Enr,
pub node_id: String,
pub node_id: NodeId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding a comment here that NodeId gets properly serialized as a 0x-prefixed hexstring

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's necessary. Since Serialize/Deserialize is derived, one should assume that serialization is done correctly.

But if you feel strong about it, I can add it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, just a nitpick

Copy link
Member

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@morph-dev morph-dev merged commit 4604caa into ethereum:master Sep 25, 2024
9 checks passed
@morph-dev morph-dev deleted the node_id_json branch September 25, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants