Add Error message when sync is still in progress. (#9475)

* 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 <seunlanlege@gmail.com>

* Update parity/cli/mod.rs

revert cli arg

Co-Authored-By: seunlanlege <seunlanlege@gmail.com>

* Apply suggestions from code review

revert config name

Co-Authored-By: seunlanlege <seunlanlege@gmail.com>

* fix PR grumbles

* fix more PR grumbles
This commit is contained in:
Seun LanLege
2018-11-26 19:58:27 +01:00
committed by Wei Tang
parent 18a2e6265d
commit f2281dc38a
8 changed files with 489 additions and 210 deletions

View File

@@ -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.",
@@ -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)]
@@ -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,
@@ -1973,6 +1979,7 @@ mod tests {
keep_alive: None,
experimental_rpcs: None,
poll_lifetime: None,
allow_missing_blocks: None
}),
ipc: Some(Ipc {
disable: None,

View File

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