This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Uncle inclusion in block authoring. #578
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c75737b
Add ancestry iterator.
gavofyork 671965d
Test for ancestry.
gavofyork 42df984
Include uncles in exclused.
gavofyork 877270c
Fixes.
gavofyork 039c005
Uncle inclusion in block authoring. Still need tests.
gavofyork 6933bb9
Test.
gavofyork 3daa4c6
Fix max uncles.
gavofyork df77f51
History to 30 to pass tests.
gavofyork 52dceff
Merge branch 'master' into finduncles
gavofyork d63e535
Merge branch 'master' into finduncles
gavofyork 098a6ad
Reset `HISTORY`.
gavofyork 86c34c7
Remove "fix".
gavofyork 8f00056
Avoid sealing unnecessarily.
gavofyork File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,7 +203,7 @@ pub struct Client { | |
extra_data: RwLock<Bytes>, | ||
} | ||
|
||
const HISTORY: u64 = 1000; | ||
const HISTORY: u64 = 30; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unintended? |
||
const CLIENT_DB_VER_STR: &'static str = "4.0"; | ||
|
||
impl Client { | ||
|
@@ -460,7 +460,7 @@ impl Client { | |
self.extra_data() | ||
); | ||
|
||
self.chain.read().unwrap().find_uncle_headers(&h).into_iter().foreach(|h| { b.push_uncle(h).unwrap(); }); | ||
self.chain.read().unwrap().find_uncle_headers(&h, self.engine.deref().deref().maximum_uncle_age()).unwrap().into_iter().foreach(|h| { b.push_uncle(h).unwrap(); }); | ||
|
||
// TODO: push transactions. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,8 @@ pub trait Engine : Sync + Send { | |
fn maximum_extra_data_size(&self) -> usize { decode(&self.spec().engine_params.get("maximumExtraDataSize").unwrap()) } | ||
/// Maximum number of uncles a block is allowed to declare. | ||
fn maximum_uncle_count(&self) -> usize { 2 } | ||
/// The number of generations back that uncles can be. | ||
fn maximum_uncle_age(&self) -> usize { 6 } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additional chain parameter |
||
/// The nonce with which accounts begin. | ||
fn account_start_nonce(&self) -> U256 { decode(&self.spec().engine_params.get("accountStartNonce").unwrap()) } | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ pub type BlockNumber = u64; | |
/// which is non-specific. | ||
/// | ||
/// Doesn't do all that much on its own. | ||
#[derive(Debug, Clone)] | ||
#[derive(Debug, Clone, Eq)] | ||
pub struct Header { | ||
// TODO: make all private. | ||
/// Parent hash. | ||
|
@@ -70,6 +70,25 @@ pub struct Header { | |
pub bare_hash: RefCell<Option<H256>>, | ||
} | ||
|
||
impl PartialEq for Header { | ||
fn eq(&self, c: &Header) -> bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comparison without the memoisation fields. |
||
self.parent_hash == c.parent_hash && | ||
self.timestamp == c.timestamp && | ||
self.number == c.number && | ||
self.author == c.author && | ||
self.transactions_root == c.transactions_root && | ||
self.uncles_hash == c.uncles_hash && | ||
self.extra_data == c.extra_data && | ||
self.state_root == c.state_root && | ||
self.receipts_root == c.receipts_root && | ||
self.log_bloom == c.log_bloom && | ||
self.gas_used == c.gas_used && | ||
self.gas_limit == c.gas_limit && | ||
self.difficulty == c.difficulty && | ||
self.seal == c.seal | ||
} | ||
} | ||
|
||
impl Default for Header { | ||
fn default() -> Self { | ||
Header { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Iterator for traversing ancestry.