Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

[devp2p discovery]: cleanup#11547

Merged
dvdplm merged 6 commits into
masterfrom
na-devp2p-cleanup-some-api
Mar 10, 2020
Merged

[devp2p discovery]: cleanup#11547
dvdplm merged 6 commits into
masterfrom
na-devp2p-cleanup-some-api

Conversation

@niklasad1
Copy link
Copy Markdown
Collaborator

@niklasad1 niklasad1 commented Mar 5, 2020

Fixes:

  • Some formatting
  • Replace manual default implementation
  • Lifetime
  • Packet_ID api, just pass by value and avoid cloning internally.

It can be merged after #11540 to avoid conflicts.

@ordian ordian added A2-insubstantial 👶 Pull request requires no code review (e.g., a sub-repository hash update). A8-looksgood 🦄 Pull request is reviewed well. labels Mar 5, 2020
Comment thread util/network-devp2p/src/discovery.rs Outdated
Copy link
Copy Markdown
Collaborator

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

lgtm; added a few suggestions (maybe for another PR?)

Comment thread util/network-devp2p/src/discovery.rs Outdated
sent_at: Instant::now(),
node: node.clone(),
echo_hash: hash,
deprecated_echo_hash: old_parity_hash,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a chance we can get rid of this you think?

Copy link
Copy Markdown
Collaborator Author

@niklasad1 niklasad1 Mar 10, 2020

Choose a reason for hiding this comment

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

what do you mean?

the entire in_flight_pings.insert ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No, I mean deprecated_echo_hash – I guess we must have made a change here at some point and kept the old hash around for backwards compatibility. Do we still have to include it you think? Can we ever remove it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Probably but I'm not sure.

fn send_packet(&mut self, packet_id: u8, address: &SocketAddr, payload: &[u8]) -> Result<H256, Error> {
fn send_packet(&mut self, packet_id: u8, address: SocketAddr, payload: &[u8]) -> Result<H256, Error> {
let packet = assemble_packet(packet_id, payload, &self.secret)?;
let hash = H256::from_slice(&packet[0..32]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a bit annoying, we just built one of these in assemble_packet(); maybe return the signed_hash from there?

Copy link
Copy Markdown
Collaborator Author

@niklasad1 niklasad1 Mar 10, 2020

Choose a reason for hiding this comment

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

hehe, right I do get your concern

In terms, of clean code if we change assemble_packet then it does clearly more than one thing but it could be quite nice if we could introduce another type Packet (or similar) to avoid copy_from_slice stuff.

But, let's address it another PR :)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you really think having assemble_packet return Result<(Bytes, H256), Error> would be so bad? It's a private method after all, and it wouldn't be doing more or different work?

But, let's address it another PR :)

Absolutely.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Do you really think having assemble_packet return Result<(Bytes, H256), Error> would be so bad? It's a private method after all, and it wouldn't be doing more or different work?

It is fine but my general opinion it should not :)

@dvdplm dvdplm merged commit b7c97f9 into master Mar 10, 2020
@dvdplm dvdplm deleted the na-devp2p-cleanup-some-api branch March 10, 2020 17:35
ordian added a commit that referenced this pull request Mar 24, 2020
* master:
  informant: display I/O stats (#11523)
  [devp2p discovery]: remove `deprecated_echo_hash` (#11564)
  [secretstore] create db_version file when database doesn't exist (#11570)
  Remove Parity's Security Policy (#11565)
  ethcore/res: enable ecip-1088 phoenix upgrade for kotti and mordor testnets (#11529)
  Misc docs and renames …and one less clone (#11556)
  [secretstore]: don't sign message with only zeroes (#11561)
  [devp2p discovery]: cleanup (#11547)
  Code cleanup in the sync module (#11552)
  initial cleanup (#11542)
  Warn if genesis constructor revert (#11550)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A2-insubstantial 👶 Pull request requires no code review (e.g., a sub-repository hash update). A8-looksgood 🦄 Pull request is reviewed well.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants