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
Return null number for pending block in eth_getBlockByNumber #8281
Merged
andresilva
merged 5 commits into
openethereum:master
from
sorpaas:issue-8028-jsonrpc-pending-number
Apr 2, 2018
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1ed3b65
Return null number for pending block in eth_getBlockByNumber
sorpaas d409966
Inline false in client_query
sorpaas 0ee2ac1
block hash for pending should be null
sorpaas a7ceb29
logsBloom should be null for pending blocks
sorpaas 96e2123
Fix test due to logsBloom type change
sorpaas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,9 +180,9 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> EthClient<C, SN, S | |
fn rich_block(&self, id: BlockNumberOrId, include_txs: bool) -> Result<Option<RichBlock>> { | ||
let client = &self.client; | ||
|
||
let client_query = |id| (client.block(id), client.block_total_difficulty(id), client.block_extra_info(id)); | ||
let client_query = |id, is_pending| (client.block(id), client.block_total_difficulty(id), client.block_extra_info(id), is_pending); | ||
|
||
let (block, difficulty, extra) = match id { | ||
let (block, difficulty, extra, is_pending) = match id { | ||
BlockNumberOrId::Number(BlockNumber::Pending) => { | ||
let info = self.client.chain_info(); | ||
let pending_block = self.miner.pending_block(info.best_block_number); | ||
|
@@ -199,7 +199,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> EthClient<C, SN, S | |
|
||
let extra = pending_block.as_ref().map(|b| self.client.engine().extra_info(&b.header)); | ||
|
||
(pending_block.map(|b| encoded::Block::new(b.rlp_bytes(Seal::Without))), Some(difficulty), extra) | ||
(pending_block.map(|b| encoded::Block::new(b.rlp_bytes(Seal::Without))), Some(difficulty), extra, true) | ||
}, | ||
|
||
BlockNumberOrId::Number(num) => { | ||
|
@@ -210,10 +210,10 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> EthClient<C, SN, S | |
BlockNumber::Pending => unreachable!(), // Already covered | ||
}; | ||
|
||
client_query(id) | ||
client_query(id, false) | ||
}, | ||
|
||
BlockNumberOrId::Id(id) => client_query(id), | ||
BlockNumberOrId::Id(id) => client_query(id, false), | ||
}; | ||
|
||
match (block, difficulty) { | ||
|
@@ -230,7 +230,10 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> EthClient<C, SN, S | |
state_root: view.state_root().into(), | ||
transactions_root: view.transactions_root().into(), | ||
receipts_root: view.receipts_root().into(), | ||
number: Some(view.number().into()), | ||
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. According to the same spec |
||
number: match is_pending { | ||
true => None, | ||
false => Some(view.number().into()), | ||
}, | ||
gas_used: view.gas_used().into(), | ||
gas_limit: view.gas_limit().into(), | ||
logs_bloom: view.log_bloom().into(), | ||
|
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.
Just inline
false
here, no point to passis_pending
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.
Ooops right.