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

Commit

Permalink
Add Error message when sync is still in progress. (#9475)
Browse files Browse the repository at this point in the history
* closes #9188

* check_for_unavailable_block in
eth_getTransactionByHash
eth_getTransactionByBlockHashAndIndex
eth_getTransactionByBlockNumberAndIndex
eth_getTransactionReceipt

* check for unavailable block in eth_getBlockByNumber

* corrected checks for unavailable_block

* check for block gaps in db

* corrected error messages

* corrected error information

* added allow-empty-block-result cli flag

* address grumbles

* --jsonrpc-allow-missing-blocks

* fix tests

* added checks to
    block_transaction_count_by_hash
    block_transaction_count_by_number
    block_uncles_count_by_hash
    block_uncles_count_by_number
    uncle_by_block_hash_and_index
    uncle_by_block_number_and_index
fix PR grumbles

* Update parity/cli/mod.rs

revert config name

Co-Authored-By: seunlanlege <[email protected]>

* Update parity/cli/mod.rs

revert cli arg

Co-Authored-By: seunlanlege <[email protected]>

* Apply suggestions from code review

revert config name

Co-Authored-By: seunlanlege <[email protected]>

* fix PR grumbles

* fix more PR grumbles
  • Loading branch information
seunlanlege authored and niklasad1 committed Dec 16, 2018
1 parent addbbf4 commit 1e56b6f
Show file tree
Hide file tree
Showing 8 changed files with 489 additions and 210 deletions.
7 changes: 7 additions & 0 deletions parity/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ usage! {


["API and Console Options – HTTP JSON-RPC"]
FLAG flag_jsonrpc_allow_missing_blocks: (bool) = false, or |c: &Config| c.rpc.as_ref()?.allow_missing_blocks.clone(),
"--jsonrpc-allow-missing-blocks",
"RPC calls will return 'null' instead of an error if ancient block sync is still in progress and the block information requested could not be found",

FLAG flag_no_jsonrpc: (bool) = false, or |c: &Config| c.rpc.as_ref()?.disable.clone(),
"--no-jsonrpc",
"Disable the HTTP JSON-RPC API server.",
Expand Down Expand Up @@ -1230,6 +1234,7 @@ struct Rpc {
keep_alive: Option<bool>,
experimental_rpcs: Option<bool>,
poll_lifetime: Option<u32>,
allow_missing_blocks: Option<bool>,
}

#[derive(Default, Debug, PartialEq, Deserialize)]
Expand Down Expand Up @@ -1697,6 +1702,7 @@ mod tests {
arg_jsonrpc_threads: 4,
arg_jsonrpc_max_payload: None,
arg_poll_lifetime: 60u32,
flag_jsonrpc_allow_missing_blocks: false,

// WS
flag_no_ws: false,
Expand Down Expand Up @@ -1973,6 +1979,7 @@ mod tests {
keep_alive: None,
experimental_rpcs: None,
poll_lifetime: None,
allow_missing_blocks: None
}),
ipc: Some(Ipc {
disable: None,
Expand Down
1 change: 1 addition & 0 deletions parity/cli/tests/config.full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ interface = "local"
cors = ["null"]
apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"]
hosts = ["none"]
allow_missing_blocks = false

[websockets]
disable = false
Expand Down
2 changes: 2 additions & 0 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ impl Configuration {
miner_extras: self.miner_extras()?,
stratum: self.stratum_options()?,
update_policy: update_policy,
allow_missing_blocks: self.args.flag_jsonrpc_allow_missing_blocks,
mode: mode,
tracing: tracing,
fat_db: fat_db,
Expand Down Expand Up @@ -1390,6 +1391,7 @@ mod tests {
let args = vec!["parity"];
let conf = parse(&args);
let mut expected = RunCmd {
allow_missing_blocks: false,
cache_config: Default::default(),
dirs: Default::default(),
spec: Default::default(),
Expand Down
Loading

0 comments on commit 1e56b6f

Please sign in to comment.