-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Removed redundant struct bounds and unnecessary data copying #9096
Conversation
@@ -488,11 +507,11 @@ impl<'x> IsBlock for OpenBlock<'x> { | |||
fn block(&self) -> &ExecutedBlock { &self.block } | |||
} | |||
|
|||
impl<'x> IsBlock for ClosedBlock { |
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.
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, ()> { |
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.
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(); |
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.
receipts and traces were copied
@@ -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 { |
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.
redundant struct bounds
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.
Code lgtm, minor doc grumbles.
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. |
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.
"…the network."
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. |
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.
"…can be appended to with transactions and uncles".
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 |
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.
"…turned into a ClosedBlock
. A ClosedBlock
can…"
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 |
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.
"…by a miner…"
ethcore/src/block.rs
Outdated
} | ||
|
||
/// Trait for a object that has a state database. | ||
/// Trait for a object that owns an `ExecutedBlock` |
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.
"…for an object…"
ethcore/src/block.rs
Outdated
@@ -599,8 +617,8 @@ impl SealedBlock { | |||
|
|||
impl Drain for SealedBlock { | |||
/// Drop this object and return the underlieing database. |
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.
"…underlying database"
Also: is it true that it's a "database" being returned with this change?
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.
it is! good catch!
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; |
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.
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?
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, and thanks for the added docs, most helpful!
//! 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. |
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.
can be appended to with transactions and uncles.
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.
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 |
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.
s/reopend/reopened
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 will fix this typo in #9117
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.
Excellent cleanup
No description provided.