fixed #1255
This commit is contained in:
parent
9940432051
commit
7610d308e8
@ -212,6 +212,7 @@ fn from_params_default_third<F1, F2>(params: Params) -> Result<(F1, F2, BlockNum
|
||||
|
||||
// must be in range [-32099, -32000]
|
||||
const UNSUPPORTED_REQUEST_CODE: i64 = -32000;
|
||||
const NO_WORK_CODE: i64 = -32001;
|
||||
|
||||
fn make_unsupported_err() -> Error {
|
||||
Error {
|
||||
@ -221,6 +222,14 @@ fn make_unsupported_err() -> Error {
|
||||
}
|
||||
}
|
||||
|
||||
fn no_work_err() -> Error {
|
||||
Error {
|
||||
code: ErrorCode::ServerError(NO_WORK_CODE),
|
||||
message: "Mining not ready.".into(),
|
||||
data: None
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM> where
|
||||
C: MiningBlockChainClient + 'static,
|
||||
S: SyncProvider + 'static,
|
||||
@ -460,7 +469,7 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM> where
|
||||
//let sync = take_weak!(self.sync);
|
||||
if /*sync.status().state != SyncState::Idle ||*/ client.queue_info().total_queue_size() > MAX_QUEUE_SIZE_TO_MINE_ON {
|
||||
trace!(target: "miner", "Syncing. Cannot give any work.");
|
||||
return to_value(&(String::new(), String::new(), String::new()));
|
||||
return Err(no_work_err());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -732,7 +732,7 @@ fn returns_no_work_if_cant_mine() {
|
||||
eth_tester.client.set_queue_size(10);
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "eth_getWork", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":["","",""],"id":1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","error":{"code":-32001,"message":"Mining not ready.","data":null},"id":1}"#;
|
||||
|
||||
assert_eq!(eth_tester.io.handle_request(request), Some(response.to_owned()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user