Add --staking flag (#1641)

## Issue Addressed

Closes #1472 

## Proposed Changes

Add `--staking` ~~and`staking-with-eth1-endpoint`~~ flag to improve UX for stakers.


Co-authored-by: Paul Hauner <paul@paulhauner.com>
This commit is contained in:
Pawan Dhananjay
2020-09-23 01:19:58 +00:00
parent b75df29501
commit 80ecafaae4
5 changed files with 60 additions and 5 deletions

View File

@@ -55,6 +55,19 @@ impl FromStr for Eth1NetworkId {
}
}
/// Checks that the provided eth1 node has all the relevant api endpoints open
/// and returns the network id.
pub async fn check_eth1_endpoint(
endpoint: &str,
timeout: Duration,
) -> Result<Eth1NetworkId, String> {
// Checks that the "eth" api works as expected.
let _block_number = get_block_number(endpoint, timeout).await?;
// Checks that the "net" api works as expected.
let network_id = get_network_id(endpoint, timeout).await?;
Ok(network_id)
}
/// Get the eth1 network id of the given endpoint.
pub async fn get_network_id(endpoint: &str, timeout: Duration) -> Result<Eth1NetworkId, String> {
let response_body = send_rpc_request(endpoint, "net_version", json!([]), timeout).await?;