Rpc: Return error if block does not exist (#11743) (#11749)

* Return error if block does not exist

* Update docs

(cherry picked from commit 747f8d5877)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
This commit is contained in:
mergify[bot]
2020-08-20 23:26:55 +00:00
committed by GitHub
parent d3ab1ec9cf
commit 096375584b
3 changed files with 15 additions and 6 deletions

View File

@@ -630,7 +630,7 @@ impl JsonRpcRequestProcessor {
self.check_slot_cleaned_up(&result, slot)?;
Ok(result.ok())
} else {
Ok(None)
Err(RpcCustomError::BlockNotAvailable { slot }.into())
}
}
@@ -702,7 +702,7 @@ impl JsonRpcRequestProcessor {
self.check_slot_cleaned_up(&result, slot)?;
Ok(result.ok().unwrap_or(None))
} else {
Ok(None)
Err(RpcCustomError::BlockNotAvailable { slot }.into())
}
}
@@ -4499,7 +4499,7 @@ pub mod tests {
slot
);
let res = io.handle_request_sync(&req, meta);
let expected = r#"{"jsonrpc":"2.0","result":null,"id":1}"#;
let expected = r#"{"jsonrpc":"2.0","error":{"code":-32004,"message":"Block not available for slot 12345"},"id":1}"#;
let expected: Response =
serde_json::from_str(&expected).expect("expected response deserialization");
let result: Response = serde_json::from_str(&res.expect("actual response"))