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

Removed redundant struct bounds and unnecessary data copying #9096

Merged
merged 2 commits into from
Jul 15, 2018

Conversation

debris
Copy link
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
@@ -488,11 +507,11 @@ impl<'x> IsBlock for OpenBlock<'x> {
fn block(&self) -> &ExecutedBlock { &self.block }
}

impl<'x> IsBlock for ClosedBlock {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

redundant lifetime

@@ -345,7 +344,7 @@ impl Importer {
imported
}

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
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

let hash = &header.hash();
let number = header.number();
let parent = header.parent_hash();
let chain = client.chain.read();

// Commit results
let receipts = block.receipts().to_owned();
let traces = block.traces().clone().drain();
Copy link
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
@@ -19,7 +19,7 @@
/// 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
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
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.

//! 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
Collaborator

Choose a reason for hiding this comment

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

"…the network."

//! 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
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".

//! 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
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…"

//! 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
Collaborator

Choose a reason for hiding this comment

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

"…by a miner…"

}

/// Trait for a object that has a state database.
/// Trait for a object that owns an `ExecutedBlock`
Copy link
Collaborator

Choose a reason for hiding this comment

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

"…for an object…"

@@ -599,8 +617,8 @@ impl SealedBlock {

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

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
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
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
//! 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
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
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"

//! 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
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
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
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