Skip to content
Snippets Groups Projects
Commit 6c49ad44 authored by Pierre Krieger's avatar Pierre Krieger Committed by Tomasz Drwięga
Browse files

Remove the RPC helpers module (#3967)

parent b8602aa5
No related merge requests found
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
/// Unwraps the trailing parameter or falls back with the closure result.
pub fn unwrap_or_else<F, H, E>(or_else: F, optional: Option<H>) -> Result<H, E> where
F: FnOnce() -> Result<H, E>,
{
match optional.into() {
None => or_else(),
Some(x) => Ok(x),
}
}
......@@ -20,7 +20,6 @@
#![warn(missing_docs)]
mod helpers;
mod metadata;
pub use api::Subscriptions;
......
......@@ -77,7 +77,7 @@ impl<B, E, Block: BlockT, RA> FullState<B, E, Block, RA>
/// Returns given block hash or best block hash if None is passed.
fn block_or_best(&self, hash: Option<Block::Hash>) -> ClientResult<Block::Hash> {
crate::helpers::unwrap_or_else(|| Ok(self.client.info().chain.best_hash), hash)
Ok(hash.unwrap_or_else(|| self.client.info().chain.best_hash))
}
/// Splits the `query_storage` block range into 'filtered' and 'unfiltered' subranges.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment