-
Notifications
You must be signed in to change notification settings - Fork 1.7k
refactor: whisper: Add type aliases and update rustdocs in message.rs #10812
Conversation
It looks like @ltfschoen signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
whisper/src/message.rs
Outdated
|
||
if data[3] & (1 << i) != 0 { | ||
idx += 256; | ||
// What does `1 << i` refer to |
There was a problem hiding this comment.
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,, ...
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe?
// 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. |
There was a problem hiding this comment.
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.
@ltfschoen merging this now, feel free to address remaining grumbles in a diff PR. |
…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)
* 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)
* 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) ...
* 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)
…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)
* [ ] Add missing memzero crate- N/A* [ ] Fix use of parity_util_mem instead of memzero- N/APreview changes