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

refactor: whisper: Add type aliases and update rustdocs in message.rs #10812

Merged
merged 2 commits into from
Jul 4, 2019

Conversation

ltfschoen
Copy link
Contributor

@ltfschoen ltfschoen commented Jun 28, 2019

  • Add types aliases to message.rs and update Rustdocs
    * [ ] Add missing memzero crate - N/A
    * [ ] Fix use of parity_util_mem instead of memzero - N/A

Preview changes

cargo doc -p parity-whisper --no-deps --open

@parity-cla-bot
Copy link

It looks like @ltfschoen signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

@ltfschoen ltfschoen added the A0-pleasereview 🤓 Pull request needs code review. label Jun 28, 2019

if data[3] & (1 << i) != 0 {
idx += 256;
// What does `1 << i` refer to
Copy link
Collaborator

@niklasad1 niklasad1 Jun 28, 2019

Choose a reason for hiding this comment

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

1 << i is the same as 2^i

thus, 2^0, 2^1, 2^2.. 2^n .. -> 1, 2, 4, 8,, ...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I for one decidedly prefer using constants or explicit numbers whenever possible.

@niklasad1
Copy link
Collaborator

@ltfschoen

[x] Add missing memzero crate
[x] Fix use of parity_util_mem instead of memzero

I can't find those changes, are they missing?

@ltfschoen
Copy link
Contributor Author

@ltfschoen

[x] Add missing memzero crate
[x] Fix use of parity_util_mem instead of memzero

I can't find those changes, are they missing?

Sorry for the confusion. I'm confused as well. I think we can ignore those dot points now. What I think happened this morning is that I got an error suggesting that use memzero needed me to add extern crate memzero, but I think VSCode may have added use memzero automatically or something. I think what's happened is that I tried adding the memzero dependency to the Cargo.toml and then adding extern crate memzero, but then I must have realised that we were using parity_util_mem instead. So then I must have reverted my memzero changes and the error went away.

Copy link
Collaborator

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

LGTM

@niklasad1 niklasad1 added A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jun 29, 2019
@ordian ordian added this to the 2.6 milestone Jun 30, 2019
Copy link
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.

Overall looks good, great job. Using the newtype pattern like this is good for readability although it miiight be a little much here: in some cases it's just easier to read H256 than SomeOtherType as it requires the reader to be familiar with the types used here. There could also be extra friction on the API borders to other code, but time will tell.

@@ -291,18 +324,23 @@ impl Message {
digest
};

// Find the best nonce based on using updating the digest with
Copy link
Collaborator

Choose a reason for hiding this comment

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

"…using updating…" – not sure what this means, can you elaborate?

// does checks for validity.
fn from_components(envelope: Envelope, size: usize, hash: H256, now: SystemTime)
// Create message from envelope, hash, and encoded size.
// Does checks for validity.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe?

Suggested change
// Does checks for validity.
// Performs validity checks

type EnvelopeProvenWork = f64;
/// Time-to-live of an envelope in seconds.
type EnvelopeTTLDuration = u64;

/// Work-factor proved. Takes 3 parameters: size of message, time to live,
/// and hash.
///
/// Panics if size or TTL is zero.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Document what the return value actually means.

@dvdplm
Copy link
Collaborator

dvdplm commented Jul 4, 2019

@ltfschoen merging this now, feel free to address remaining grumbles in a diff PR.

@dvdplm dvdplm merged commit bacc0f0 into master Jul 4, 2019
dvdplm added a commit that referenced this pull request Jul 4, 2019
…me-parent

* master:
  refactor: whisper: Add type aliases and update rustdocs in message.rs (#10812)
  Break circular dependency between Client and Engine (part 1) (#10833)
  tests: Relates to #10655: Test instructions for Readme (#10835)
  refactor: Related #9459 - evmbin: replace untyped json! macro with fully typed serde serialization using Rust structs (#10657)
  idiomatic changes to PodState (#10834)
  Allow --nat extip:your.host.here.org (#10830)
  When updating the client or when called from RPC, sleep should mean sleep (#10814)
  Remove excessive warning (#10831)
  Fix typo in README.md (#10828)
  ethcore does not use byteorder (#10829)
  Better logging when backfilling ancient blocks fail (#10796)
  depends: Update wordlist to v1.3 (#10823)
dvdplm added a commit that referenced this pull request Jul 4, 2019
* master:
  refactor: whisper: Add type aliases and update rustdocs in message.rs (#10812)
  Break circular dependency between Client and Engine (part 1) (#10833)
  tests: Relates to #10655: Test instructions for Readme (#10835)
  refactor: Related #9459 - evmbin: replace untyped json! macro with fully typed serde serialization using Rust structs (#10657)
  idiomatic changes to PodState (#10834)
  Allow --nat extip:your.host.here.org (#10830)
  When updating the client or when called from RPC, sleep should mean sleep (#10814)
  Remove excessive warning (#10831)
  Fix typo in README.md (#10828)
  ethcore does not use byteorder (#10829)
  Better logging when backfilling ancient blocks fail (#10796)
  depends: Update wordlist to v1.3 (#10823)
  cargo update -p smallvec (#10822)
  replace memzero with zeroize crate (#10816)
  Don't repeat the logic from Default impl (#10813)
  removed additional_params method (#10818)
  Add Constantinople eips to the dev (instant_seal) config (#10809)
dvdplm added a commit that referenced this pull request Jul 4, 2019
* master: (21 commits)
  refactor: whisper: Add type aliases and update rustdocs in message.rs (#10812)
  Break circular dependency between Client and Engine (part 1) (#10833)
  tests: Relates to #10655: Test instructions for Readme (#10835)
  refactor: Related #9459 - evmbin: replace untyped json! macro with fully typed serde serialization using Rust structs (#10657)
  idiomatic changes to PodState (#10834)
  Allow --nat extip:your.host.here.org (#10830)
  When updating the client or when called from RPC, sleep should mean sleep (#10814)
  Remove excessive warning (#10831)
  Fix typo in README.md (#10828)
  ethcore does not use byteorder (#10829)
  Better logging when backfilling ancient blocks fail (#10796)
  depends: Update wordlist to v1.3 (#10823)
  cargo update -p smallvec (#10822)
  replace memzero with zeroize crate (#10816)
  Don't repeat the logic from Default impl (#10813)
  removed additional_params method (#10818)
  Add Constantinople eips to the dev (instant_seal) config (#10809)
  removed redundant fmt::Display implementations (#10806)
  revert changes to .gitlab-ci.yml (#10807)
  Add filtering capability to `parity_pendingTransactions` (issue 8269) (#10506)
  ...
dvdplm added a commit that referenced this pull request Jul 4, 2019
* master:
  Extricate PodAccount and state Account to own crates (#10838)
  logs (#10817)
  refactor: whisper: Add type aliases and update rustdocs in message.rs (#10812)
  Break circular dependency between Client and Engine (part 1) (#10833)
  tests: Relates to #10655: Test instructions for Readme (#10835)
  refactor: Related #9459 - evmbin: replace untyped json! macro with fully typed serde serialization using Rust structs (#10657)
dvdplm added a commit that referenced this pull request Jul 4, 2019
…hore/extricate-state-backend

* dp/chore/extricate-account-db-into-own-crate:
  third time's the charm
  test failure 2
  test failure
  Extricate PodAccount and state Account to own crates (#10838)
  logs (#10817)
  refactor: whisper: Add type aliases and update rustdocs in message.rs (#10812)
  Break circular dependency between Client and Engine (part 1) (#10833)
  tests: Relates to #10655: Test instructions for Readme (#10835)
  refactor: Related #9459 - evmbin: replace untyped json! macro with fully typed serde serialization using Rust structs (#10657)
@niklasad1 niklasad1 deleted the luke-whisper-message-refactor branch November 12, 2019 20:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants