Skip to content

Commit

Permalink
Update peer_count return type (#263)
Browse files Browse the repository at this point in the history
* Update peer_count return type

* Fix ci
  • Loading branch information
boundless-forest authored Jan 5, 2021
1 parent 378221a commit 78fb3bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/rpc-core/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub trait NetApi {

/// Returns number of peers connected to node.
#[rpc(name = "net_peerCount")]
fn peer_count(&self) -> Result<String>;
fn peer_count(&self) -> Result<u32>;

/// Returns true if client is actively listening for network connections.
/// Otherwise false.
Expand Down
8 changes: 4 additions & 4 deletions client/rpc/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl<B, C, P, CT, BE, H: ExHashT> EthApiT for EthApi<B, C, P, CT, BE, H> where
fn syncing(&self) -> Result<SyncStatus> {
if self.network.is_major_syncing() {
let block_number = U256::from(
self.client.info().best_number.clone().unique_saturated_into()
UniqueSaturatedInto::<u128>::unique_saturated_into(self.client.info().best_number.clone())
);
Ok(SyncStatus::Info(SyncInfo {
starting_block: U256::zero(),
Expand Down Expand Up @@ -325,7 +325,7 @@ impl<B, C, P, CT, BE, H: ExHashT> EthApiT for EthApi<B, C, P, CT, BE, H> where
}

fn block_number(&self) -> Result<U256> {
Ok(U256::from(self.client.info().best_number.clone().unique_saturated_into()))
Ok(U256::from(UniqueSaturatedInto::<u128>::unique_saturated_into(self.client.info().best_number.clone())))
}

fn balance(&self, address: H160, number: Option<BlockNumber>) -> Result<U256> {
Expand Down Expand Up @@ -1074,8 +1074,8 @@ impl<B: BlockT, BE, C, H: ExHashT> NetApiT for NetApi<B, BE, C, H> where
Ok(true)
}

fn peer_count(&self) -> Result<String> {
Ok((self.network.num_connected() as u32).to_string())
fn peer_count(&self) -> Result<u32> {
Ok(self.network.num_connected() as u32)
}

fn version(&self) -> Result<String> {
Expand Down

0 comments on commit 78fb3bc

Please sign in to comment.