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

Removed redundant struct bounds and unnecessary data copying#9096

Merged
debris merged 2 commits into
masterfrom
block_cleanup
Jul 15, 2018
Merged

Removed redundant struct bounds and unnecessary data copying#9096
debris merged 2 commits into
masterfrom
block_cleanup

Conversation

@debris
Copy link
Copy Markdown
Collaborator

@debris debris commented Jul 11, 2018

No description provided.

@debris debris added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Jul 11, 2018
Comment thread ethcore/src/block.rs
fn block(&self) -> &ExecutedBlock { &self.block }
}

impl<'x> IsBlock for ClosedBlock {
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.

redundant lifetime

}

fn check_and_close_block(&self, block: PreverifiedBlock, client: &Client) -> Result<LockedBlock, ()> {
fn check_and_lock_block(&self, block: PreverifiedBlock, client: &Client) -> Result<LockedBlock, ()> {
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.

renamed, cause the function returns LockedBlock, not ClosedBlock


// Commit results
let receipts = block.receipts().to_owned();
let traces = block.traces().clone().drain();
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.

receipts and traces were copied

@5chdn 5chdn added this to the 2.1 milestone Jul 11, 2018
/// Special queue-like datastructure that includes the notion of
/// usage to avoid items that were queued but never used from making it into
/// the queue.
pub struct UsingQueue<T> where T: Clone {
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.

redundant struct bounds

dvdplm
dvdplm previously requested changes Jul 12, 2018
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.

Code lgtm, minor doc grumbles.

Comment thread ethcore/src/block.rs Outdated
//! Blockchain block.
//! Base data structure of this module is `Block`.
//!
//! Blocks can be produced by a local node or they may be received from network.
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.

"…the network."

Comment thread ethcore/src/block.rs Outdated
//! Blocks can be produced by a local node or they may be received from network.
//!
//! To create a block locally, we start with an `OpenBlock`. This block is mutable
//! and can be appended with transactions and uncles.
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.

"…can be appended to with transactions and uncles".

Comment thread ethcore/src/block.rs Outdated
//! To create a block locally, we start with an `OpenBlock`. This block is mutable
//! and can be appended with transactions and uncles.
//!
//! When ready, `OpenBlock` can be closed and turned into `ClosedBlock`. `ClosedBlock` can
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.

"…turned into a ClosedBlock. A ClosedBlock can…"

Comment thread ethcore/src/block.rs Outdated
//! and can be appended with transactions and uncles.
//!
//! When ready, `OpenBlock` can be closed and turned into `ClosedBlock`. `ClosedBlock` can
//! be reopend again by miner under certain circumstances. On block close, state commit is
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.

"…by a miner…"

Comment thread ethcore/src/block.rs Outdated
}

/// Trait for a object that has a state database.
/// Trait for a object that owns an `ExecutedBlock`
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.

"…for an object…"

Comment thread ethcore/src/block.rs Outdated
@@ -599,8 +617,8 @@ impl SealedBlock {

impl Drain for SealedBlock {
/// Drop this object and return the underlieing database.
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.

"…underlying database"

Also: is it true that it's a "database" being returned with this change?

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.

it is! good catch!

Comment thread ethcore/src/client/client.rs Outdated
let metadata = block.block().metadata().map(Into::into);
let is_finalized = block.block().is_finalized();
let metadata = block.metadata;
let is_finalized = block.is_finalized;
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 need to make new bindings like this? Maybe it's more readable to see block.is_finalized further down the code, makes it obvious where it's coming from if one reads only parts of the method?

@debris debris dismissed dvdplm’s stale review July 12, 2018 11:51

fixed! Thanks for the review! :)

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, and thanks for the added docs, most helpful!

@5chdn 5chdn requested a review from grbIzl July 13, 2018 10:20
@5chdn 5chdn added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jul 13, 2018
Comment thread ethcore/src/block.rs
//! Blocks can be produced by a local node or they may be received from the network.
//!
//! To create a block locally, we start with an `OpenBlock`. This block is mutable
//! and can be appended to with transactions and uncles.
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.

can be appended to with transactions and uncles.

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 this is correct, "She appended an item to the list using a magnet" => "The list was appended to with a magnet"

Comment thread ethcore/src/block.rs
//! and can be appended to with transactions and uncles.
//!
//! When ready, `OpenBlock` can be closed and turned into a `ClosedBlock`. A `ClosedBlock` can
//! be reopend again by a miner under certain circumstances. On block close, state commit is
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.

s/reopend/reopened

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.

I will fix this typo in #9117

@niklasad1 niklasad1 added A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. and removed A8-looksgood 🦄 Pull request is reviewed well. labels Jul 13, 2018
Copy link
Copy Markdown
Collaborator

@grbIzl grbIzl left a comment

Choose a reason for hiding this comment

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

Excellent cleanup

@debris debris merged commit f826ac3 into master Jul 15, 2018
@debris debris deleted the block_cleanup branch July 15, 2018 09:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. M4-core ⛓ Core client code / Rust.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants