Simplify some Option / Result / ? operator patterns (#8653)

* Simplify some Option / Result / ? operator patterns

When those match a combinator exactly.

Tool-aided by [comby-rust](https://github.com/huitseeker/comby-rust).

* adjust after review

* adjust post-review
This commit is contained in:
François Garillot
2021-04-23 09:36:10 -04:00
committed by GitHub
parent 541692c4a8
commit 052be8bbef
37 changed files with 77 additions and 188 deletions
@@ -99,8 +99,7 @@ fn replace_path_dependencies_with_git(cargo_toml_path: &Path, commit_id: &str, c
let deps_rewritten = dependencies
.iter()
.filter_map(|(k, v)| v.clone().try_into::<toml::value::Table>().ok().map(move |v| (k, v)))
.filter(|t| t.1.contains_key("path"))
.filter(|t| {
.filter(|t| t.1.contains_key("path") && {
// if the path does not exists, we need to add this as git dependency
t.1.get("path").unwrap().as_str().map(|path| !cargo_toml_path.join(path).exists()).unwrap_or(false)
})
+3 -6
View File
@@ -218,12 +218,9 @@ pub fn for_each_cht_group<Header, I, F, P>(
let mut current_cht_num = None;
let mut current_cht_blocks = Vec::new();
for block in blocks {
let new_cht_num = match block_to_cht_number(cht_size, block) {
Some(new_cht_num) => new_cht_num,
None => return Err(ClientError::Backend(format!(
"Cannot compute CHT root for the block #{}", block)).into()
),
};
let new_cht_num = block_to_cht_number(cht_size, block).ok_or_else(|| ClientError::Backend(format!(
"Cannot compute CHT root for the block #{}", block))
)?;
let advance_to_next_cht = current_cht_num.is_some() && current_cht_num != Some(new_cht_num);
if advance_to_next_cht {
+4 -8
View File
@@ -226,10 +226,8 @@ impl<Block: BlockT> Blockchain<Block> {
/// Set an existing block as head.
pub fn set_head(&self, id: BlockId<Block>) -> sp_blockchain::Result<()> {
let header = match self.header(id)? {
Some(h) => h,
None => return Err(sp_blockchain::Error::UnknownBlock(format!("{}", id))),
};
let header = self.header(id)?
.ok_or_else(|| sp_blockchain::Error::UnknownBlock(format!("{}", id)))?;
self.apply_head(&header)
}
@@ -760,10 +758,8 @@ impl<Block: BlockT> backend::Backend<Block> for Backend<Block> where Block::Hash
_ => {},
}
match self.blockchain.id(block).and_then(|id| self.states.read().get(&id).cloned()) {
Some(state) => Ok(state),
None => Err(sp_blockchain::Error::UnknownBlock(format!("{}", block))),
}
self.blockchain.id(block).and_then(|id| self.states.read().get(&id).cloned())
.ok_or_else(|| sp_blockchain::Error::UnknownBlock(format!("{}", block)))
}
fn revert(
+7 -8
View File
@@ -51,19 +51,18 @@ impl StorageChangeSet {
.map(move |(k,v)| (None, k, v.as_ref()));
let children = self.child_changes
.iter()
.filter_map(move |(sk, changes)| {
if let Some(cf) = self.child_filters.as_ref() {
if let Some(filter) = cf.get(sk) {
Some(changes
.filter_map(move |(sk, changes)|
self.child_filters.as_ref().and_then(|cf|
cf.get(sk).map(|filter| changes
.iter()
.filter(move |&(key, _)| match filter {
Some(ref filter) => filter.contains(key),
None => true,
})
.map(move |(k,v)| (Some(sk), k, v.as_ref())))
} else { None }
} else { None }
})
.map(move |(k,v)| (Some(sk), k, v.as_ref()))
)
)
)
.flatten();
top.chain(children)
}
@@ -72,10 +72,7 @@ fn check_header<C, B: BlockT, P: Pair>(
C: sc_client_api::backend::AuxStore,
P::Public: Encode + Decode + PartialEq + Clone,
{
let seal = match header.digest_mut().pop() {
Some(x) => x,
None => return Err(Error::HeaderUnsealed(hash)),
};
let seal = header.digest_mut().pop().ok_or_else(|| Error::HeaderUnsealed(hash))?;
let sig = seal.as_aura_seal().ok_or_else(|| {
aura_err(Error::HeaderBadSeal(hash))
@@ -89,10 +86,8 @@ fn check_header<C, B: BlockT, P: Pair>(
} else {
// check the signature is valid under the expected authority and
// chain state.
let expected_author = match slot_author::<P>(slot, &authorities) {
None => return Err(Error::SlotAuthorNotFound),
Some(author) => author,
};
let expected_author = slot_author::<P>(slot, &authorities)
.ok_or_else(|| Error::SlotAuthorNotFound)?;
let pre_hash = header.hash();
@@ -71,10 +71,8 @@ pub(super) fn check_header<B: BlockT + Sized>(
let pre_digest = pre_digest.map(Ok).unwrap_or_else(|| find_pre_digest::<B>(&header))?;
trace!(target: "babe", "Checking header");
let seal = match header.digest_mut().pop() {
Some(x) => x,
None => return Err(babe_err(Error::HeaderUnsealed(header.hash()))),
};
let seal = header.digest_mut().pop()
.ok_or_else(|| babe_err(Error::HeaderUnsealed(header.hash())))?;
let sig = seal.as_babe_seal().ok_or_else(|| {
babe_err(Error::HeaderBadSeal(header.hash()))
@@ -104,10 +104,7 @@ pub async fn seal_block<B, BI, SC, C, E, P>(
// or fetch the best_block.
let parent = match parent_hash {
Some(hash) => {
match client.header(BlockId::Hash(hash))? {
Some(header) => header,
None => return Err(Error::BlockNotFound(format!("{}", hash))),
}
client.header(BlockId::Hash(hash))?.ok_or_else(|| Error::BlockNotFound(format!("{}", hash)))?
}
None => select_chain.best_chain()?
};
+1 -4
View File
@@ -256,10 +256,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
return None;
}
let claim = match self.claim_slot(&chain_head, slot, &epoch_data) {
None => return None,
Some(claim) => claim,
};
let claim = self.claim_slot(&chain_head, slot, &epoch_data)?;
if self.should_backoff(slot, &chain_head) {
return None;
@@ -135,10 +135,7 @@ impl<SC: SlotCompatible> Slots<SC> {
Err(err) => return Err(sp_consensus::Error::InherentData(err)),
};
let result = self.timestamp_extractor.extract_timestamp_and_slot(&inherent_data);
let (timestamp, slot, offset) = match result {
Ok(v) => v,
Err(err) => return Err(err),
};
let (timestamp, slot, offset) = result?;
// reschedule delay for next slot.
let ends_in = offset +
time_until_next(timestamp.as_duration(), self.slot_duration);
@@ -503,10 +503,8 @@ fn read_tries_meta<Block: BlockT>(
meta_column: u32,
) -> ClientResult<ChangesTriesMeta<Block>> {
match db.get(meta_column, meta_keys::CHANGES_TRIES_META) {
Some(h) => match Decode::decode(&mut &h[..]) {
Ok(h) => Ok(h),
Err(err) => Err(ClientError::Backend(format!("Error decoding changes tries metadata: {}", err))),
},
Some(h) => Decode::decode(&mut &h[..])
.map_err(|err| ClientError::Backend(format!("Error decoding changes tries metadata: {}", err))),
None => Ok(ChangesTriesMeta {
oldest_digest_range: None,
oldest_pruned_digest_range_end: Zero::zero(),
+2 -4
View File
@@ -395,10 +395,8 @@ pub fn read_meta<Block>(db: &dyn Database<DbHash>, col_header: u32) -> Result<
};
let load_meta_block = |desc, key| -> Result<_, sp_blockchain::Error> {
if let Some(Some(header)) = match db.get(COLUMN_META, key) {
Some(id) => db.get(col_header, &id).map(|b| Block::Header::decode(&mut &b[..]).ok()),
None => None,
}
if let Some(Some(header)) = db.get(COLUMN_META, key)
.and_then(|id| db.get(col_header, &id).map(|b| Block::Header::decode(&mut &b[..]).ok()))
{
let hash = header.hash();
debug!(
@@ -289,14 +289,10 @@ where
fn consume(
mut self,
) -> Option<(AuthoritySet<H, N>, SharedDataLocked<'a, AuthoritySet<H, N>>)> {
if let Some(old) = self.old.take() {
Some((
self.old.take().map(|old| (
old,
self.guard.take().expect("only taken on deconstruction; qed"),
))
} else {
None
}
))
}
}
+8 -9
View File
@@ -1134,13 +1134,12 @@ fn local_authority_id(
voters: &VoterSet<AuthorityId>,
keystore: Option<&SyncCryptoStorePtr>,
) -> Option<AuthorityId> {
match keystore {
Some(keystore) => voters
.iter()
.find(|(p, _)| {
SyncCryptoStore::has_keys(&**keystore, &[(p.to_raw_vec(), AuthorityId::ID)])
})
.map(|(p, _)| p.clone()),
None => None,
}
keystore.and_then(|keystore| {
voters
.iter()
.find(|(p, _)| {
SyncCryptoStore::has_keys(&**keystore, &[(p.to_raw_vec(), AuthorityId::ID)])
})
.map(|(p, _)| p.clone())
})
}
+1 -4
View File
@@ -330,10 +330,7 @@ impl<'a, H, Number, Hash> ChangesTrieRootsStorage<H, Number> for RootsStorage<'a
self.prev_roots.get(&Number::unique_saturated_from(block)).cloned()
} else {
let index: Option<usize> = block.checked_sub(&self.roots.0).and_then(|index| index.checked_into());
match index {
Some(index) => self.roots.1.get(index as usize).cloned(),
None => None,
}
index.and_then(|index| self.roots.1.get(index as usize).cloned())
};
Ok(root.map(|root| {
+1 -4
View File
@@ -183,10 +183,7 @@ impl HttpApi {
) -> Result<(), HttpError> {
// Extract the request from the list.
// Don't forget to add it back if necessary when returning.
let mut request = match self.requests.remove(&request_id) {
None => return Err(HttpError::Invalid),
Some(r) => r,
};
let mut request = self.requests.remove(&request_id).ok_or_else(|| HttpError::Invalid)?;
let mut deadline = timestamp::deadline_to_future(deadline);
// Closure that writes data to a sender, taking the deadline into account. Can return `Ok`
+1 -5
View File
@@ -272,15 +272,11 @@ impl PeersState {
})
.map(|(peer_id, _)| peer_id.clone());
if let Some(peer_id) = outcome {
Some(NotConnectedPeer {
outcome.map(move |peer_id| NotConnectedPeer {
state: self,
set,
peer_id: Cow::Owned(peer_id),
})
} else {
None
}
}
/// Returns `true` if there is a free outgoing slot available related to this set.
@@ -722,13 +722,10 @@ fn maybe_share_remote_request<Block: BlockT, Requests, V, IssueRequest, IssueReq
fn display_error<F, T>(future: F) -> impl std::future::Future<Output=Result<T, ()>> where
F: std::future::Future<Output=Result<T, Error>>
{
future.then(|result| ready(match result {
Ok(result) => Ok(result),
Err(err) => {
future.then(|result| ready(result.or_else(|err| {
warn!("Remote request for subscription data has failed with: {:?}", err);
Err(())
},
}))
})))
}
/// Convert successful future result into Ok(Some(result)) and error into Ok(None),
@@ -585,10 +585,8 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
&dyn PrunableStateChangesTrieStorage<Block>,
Vec<(NumberFor<Block>, Option<(NumberFor<Block>, Block::Hash)>, ChangesTrieConfiguration)>,
)> {
let storage = match self.backend.changes_trie_storage() {
Some(storage) => storage,
None => return Err(sp_blockchain::Error::ChangesTriesNotSupported),
};
let storage = self.backend.changes_trie_storage()
.ok_or_else(|| sp_blockchain::Error::ChangesTriesNotSupported)?;
let mut configs = Vec::with_capacity(1);
let mut current = last;
@@ -1153,10 +1151,8 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
/// Gets the uncles of the block with `target_hash` going back `max_generation` ancestors.
pub fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor<Block>) -> sp_blockchain::Result<Vec<Block::Hash>> {
let load_header = |id: Block::Hash| -> sp_blockchain::Result<Block::Header> {
match self.backend.blockchain().header(BlockId::Hash(id))? {
Some(hdr) => Ok(hdr),
None => Err(Error::UnknownBlock(format!("{:?}", id))),
}
self.backend.blockchain().header(BlockId::Hash(id))?
.ok_or_else(|| Error::UnknownBlock(format!("{:?}", id)))
};
let genesis_hash = self.backend.blockchain().info().genesis_hash;
+5 -7
View File
@@ -391,9 +391,8 @@ fn start_rpc_servers<
) -> Result<Box<dyn std::any::Any + Send + Sync>, error::Error> {
fn maybe_start_server<T, F>(address: Option<SocketAddr>, mut start: F) -> Result<Option<T>, io::Error>
where F: FnMut(&SocketAddr) -> Result<T, io::Error>,
{
Ok(match address {
Some(mut address) => Some(start(&address)
{
address.map(|mut address| start(&address)
.or_else(|e| match e.kind() {
io::ErrorKind::AddrInUse |
io::ErrorKind::PermissionDenied => {
@@ -402,10 +401,9 @@ fn start_rpc_servers<
start(&address)
},
_ => Err(e),
})?),
None => None,
})
}
}
) ).transpose()
}
fn deny_unsafe(addr: &SocketAddr, methods: &RpcMethods) -> sc_rpc::DenyUnsafe {
let is_exposed_addr = !addr.ip().is_loopback();
@@ -150,10 +150,8 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
pub fn new<D: MetaDb>(db: &D) -> Result<NonCanonicalOverlay<BlockHash, Key>, Error<D::Error>> {
let last_canonicalized = db.get_meta(&to_meta_key(LAST_CANONICAL, &()))
.map_err(|e| Error::Db(e))?;
let last_canonicalized = match last_canonicalized {
Some(buffer) => Some(<(BlockHash, u64)>::decode(&mut buffer.as_slice())?),
None => None,
};
let last_canonicalized = last_canonicalized
.map(|buffer| <(BlockHash, u64)>::decode(&mut buffer.as_slice())).transpose()?;
let mut levels = VecDeque::new();
let mut parents = HashMap::new();
let mut values = HashMap::new();
+1 -4
View File
@@ -389,10 +389,7 @@ impl Telemetry {
/// The `connection_message` argument is a JSON object that is sent every time the connection
/// (re-)establishes.
pub fn start_telemetry(&mut self, connection_message: ConnectionMessage) -> Result<()> {
let endpoints = match self.endpoints.take() {
Some(x) => x,
None => return Err(Error::TelemetryAlreadyInitialized),
};
let endpoints = self.endpoints.take().ok_or_else(|| Error::TelemetryAlreadyInitialized)?;
self.register_sender
.unbounded_send(Register::Telemetry {
+1 -1
View File
@@ -246,7 +246,7 @@ fn parse_target(s: &str) -> (String, Level) {
Some(i) => {
let target = s[0..i].to_string();
if s.len() > i {
let level = s[i + 1..s.len()].parse::<Level>().unwrap_or(Level::TRACE);
let level = s[i + 1..].parse::<Level>().unwrap_or(Level::TRACE);
(target, level)
} else {
(target, Level::TRACE)
@@ -322,10 +322,7 @@ impl<B: ChainApi> Pool<B> {
) -> Result<(), B::Error> {
log::debug!(target: "txpool", "Pruning at {:?}", at);
// Prune all transactions that provide given tags
let prune_status = match self.validated_pool.prune_tags(tags) {
Ok(prune_status) => prune_status,
Err(e) => return Err(e),
};
let prune_status = self.validated_pool.prune_tags(tags)?;
// Make sure that we don't revalidate extrinsics that were part of the recently
// imported block. This is especially important for UTXO-like chains cause the
@@ -527,12 +527,9 @@ impl<Hash: hash::Hash + Member, Ex> Iterator for BestIterator<Hash, Ex> {
satisfied += 1;
Some((satisfied, tx_ref))
// then get from the pool
} else if let Some(next) = self.all.read().get(hash) {
Some((next.requires_offset + 1, next.transaction.clone()))
} else {
None
self.all.read().get(hash).map(|next| (next.requires_offset + 1, next.transaction.clone()))
};
if let Some((satisfied, tx_ref)) = res {
self.best_or_awaiting(satisfied, tx_ref)
}
+1 -4
View File
@@ -163,10 +163,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
who: &T::AccountId,
keep_alive: bool,
) -> Result<T::Balance, Error<T, I>> {
let details = match Asset::<T, I>::get(id) {
Some(details) => details,
None => return Err(Error::<T, I>::Unknown),
};
let details = Asset::<T, I>::get(id).ok_or_else(|| Error::<T, I>::Unknown)?;
ensure!(!details.is_frozen, Error::<T, I>::Frozen);
let account = Account::<T, I>::get(id, who);
+1 -4
View File
@@ -490,10 +490,7 @@ mod tests {
let pre_runtime_digests = header.digest.logs.iter().filter_map(|d| d.as_pre_runtime());
let seals = header.digest.logs.iter().filter_map(|d| d.as_seal());
let author = match AuthorGiven::find_author(pre_runtime_digests) {
None => return Err("no author"),
Some(author) => author,
};
let author = AuthorGiven::find_author(pre_runtime_digests).ok_or_else(|| "no author")?;
for (id, seal) in seals {
if id == TEST_ID {
+1 -4
View File
@@ -127,10 +127,7 @@ where
}
let amount = token.calculate_amount(metadata);
let new_value = match self.gas_left.checked_sub(amount) {
None => None,
Some(val) => Some(val),
};
let new_value = self.gas_left.checked_sub(amount);
// We always consume the gas even if there is not enough gas.
self.gas_left = new_value.unwrap_or_else(Zero::zero);
+1 -5
View File
@@ -26,16 +26,12 @@ pub fn migrate<T: Config>() -> Weight {
Some(version) if version == PalletVersion::new(3, 0, 0) => {
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));
let _ = <CurrentSchedule<T>>::translate::<u32, _>(|version| {
if let Some(version) = version {
Some(Schedule {
version.map(|version| Schedule {
version: version.saturating_add(1),
// Default limits were not decreased. Therefore it is OK to overwrite
// the schedule with the new defaults.
.. Default::default()
})
} else {
None
}
});
}
_ => (),
+1 -4
View File
@@ -407,10 +407,7 @@ where
);
// Check what happened after enaction of the verdict.
let alive_contract_info = match new_contract_info.map_err(|_| IsTombstone)? {
None => return Err(IsTombstone),
Some(contract) => contract,
};
let alive_contract_info = new_contract_info.map_err(|_| IsTombstone)?.ok_or_else(|| IsTombstone)?;
// Compute how much would the fee per block be with the *updated* balance.
let total_balance = T::Currency::total_balance(account);
+3 -12
View File
@@ -1653,10 +1653,7 @@ impl<T: Config> Module<T> {
// To decode the enum variant we only need the first byte.
let mut buf = [0u8; 1];
let key = <Preimages<T>>::hashed_key_for(proposal_hash);
let bytes = match sp_io::storage::read(&key, &mut buf, 0) {
Some(bytes) => bytes,
None => return Err(Error::<T>::NotImminent.into()),
};
let bytes = sp_io::storage::read(&key, &mut buf, 0).ok_or_else(|| Error::<T>::NotImminent)?;
// The value may be smaller that 1 byte.
let mut input = &buf[0..buf.len().min(bytes as usize)];
@@ -1684,10 +1681,7 @@ impl<T: Config> Module<T> {
// * at most 5 bytes to decode a `Compact<u32>`
let mut buf = [0u8; 6];
let key = <Preimages<T>>::hashed_key_for(proposal_hash);
let bytes = match sp_io::storage::read(&key, &mut buf, 0) {
Some(bytes) => bytes,
None => return Err(Error::<T>::PreimageMissing.into()),
};
let bytes = sp_io::storage::read(&key, &mut buf, 0).ok_or_else(|| Error::<T>::PreimageMissing)?;
// The value may be smaller that 6 bytes.
let mut input = &buf[0..buf.len().min(bytes as usize)];
@@ -1761,10 +1755,7 @@ impl<T: Config> Module<T> {
fn decode_compact_u32_at(key: &[u8]) -> Option<u32> {
// `Compact<u32>` takes at most 5 bytes.
let mut buf = [0u8; 5];
let bytes = match sp_io::storage::read(&key, &mut buf, 0) {
Some(bytes) => bytes,
None => return None,
};
let bytes = sp_io::storage::read(&key, &mut buf, 0)?;
// The value may be smaller than 5 bytes.
let mut input = &buf[0..buf.len().min(bytes as usize)];
match codec::Compact::<u32>::decode(&mut input) {
+2 -10
View File
@@ -518,21 +518,13 @@ impl<T: Config> Module<T> {
None
} else {
let session_index =
if let Some(session_id) = Self::session_for_set(set_id - 1) {
session_id
} else {
return Err(Error::<T>::InvalidEquivocationProof.into());
};
Self::session_for_set(set_id - 1).ok_or_else(|| Error::<T>::InvalidEquivocationProof)?;
Some(session_index)
};
let set_id_session_index =
if let Some(session_id) = Self::session_for_set(set_id) {
session_id
} else {
return Err(Error::<T>::InvalidEquivocationProof.into());
};
Self::session_for_set(set_id).ok_or_else(|| Error::<T>::InvalidEquivocationProof)?;
// check that the session id for the membership proof is within the
// bounds of the set id reported in the equivocation.
+2 -5
View File
@@ -2736,11 +2736,8 @@ impl<T: Config> Convert<T::AccountId, Option<Exposure<T::AccountId, BalanceOf<T>
for ExposureOf<T>
{
fn convert(validator: T::AccountId) -> Option<Exposure<T::AccountId, BalanceOf<T>>> {
if let Some(active_era) = <Module<T>>::active_era() {
Some(<Module<T>>::eras_stakers(active_era.index, &validator))
} else {
None
}
<Module<T>>::active_era()
.map(|active_era| <Module<T>>::eras_stakers(active_era.index, &validator))
}
}
@@ -77,10 +77,8 @@ impl<T: FullCodec, G: StorageValue<T>> storage::StorageValue<T> for G {
let key = Self::storage_value_final_key();
// attempt to get the length directly.
let maybe_old = match unhashed::get_raw(&key) {
Some(old_data) => Some(O::decode(&mut &old_data[..]).map_err(|_| ())?),
None => None,
};
let maybe_old = unhashed::get_raw(&key)
.map(|old_data| O::decode(&mut &old_data[..]).map_err(|_| ())).transpose()?;
let maybe_new = f(maybe_old);
if let Some(new) = maybe_new.as_ref() {
new.using_encoded(|d| unhashed::put_raw(&key, d));
@@ -195,7 +195,7 @@ pub fn extract_all_signature_types(items: &[ImplItem]) -> Vec<Type> {
ImplItem::Method(method) => Some(&method.sig),
_ => None,
})
.map(|sig| {
.flat_map(|sig| {
let ret_ty = match &sig.output {
ReturnType::Default => None,
ReturnType::Type(_, ty) => Some((**ty).clone()),
@@ -209,7 +209,6 @@ pub fn extract_all_signature_types(items: &[ImplItem]) -> Vec<Type> {
_ => (**ty).clone(),
}).chain(ret_ty)
})
.flatten()
.collect()
}
@@ -237,13 +237,10 @@ impl<Block: BlockT, Transaction> BlockImportParams<Block, Transaction> {
pub fn take_intermediate<T: 'static>(&mut self, key: &[u8]) -> Result<Box<T>, Error> {
let (k, v) = self.intermediates.remove_entry(key).ok_or(Error::NoIntermediate)?;
match v.downcast::<T>() {
Ok(v) => Ok(v),
Err(v) => {
v.downcast::<T>().or_else(|v| {
self.intermediates.insert(k, v);
Err(Error::InvalidIntermediate)
},
}
})
}
/// Get a reference to a given intermediate.
+1 -4
View File
@@ -207,10 +207,7 @@ where
let call_data = account.encode();
let future_best_header = future_best_header
.and_then(move |maybe_best_header| ready(
match maybe_best_header {
Some(best_header) => Ok(best_header),
None => Err(ClientError::UnknownBlock(format!("{}", best_hash))),
}
maybe_best_header.ok_or_else(|| { ClientError::UnknownBlock(format!("{}", best_hash)) })
));
let future_nonce = future_best_header.and_then(move |best_header|
fetcher.remote_call(RemoteCallRequest {
@@ -169,10 +169,8 @@ impl TryRuntimeCmd {
uri: url.into(),
state_snapshot: snapshot_path.as_ref().map(SnapshotConfig::new),
modules: modules.clone().unwrap_or_default(),
at: match block_at {
Some(b) => Some(b.parse().map_err(|e| format!("Could not parse hash: {:?}", e))?),
None => None,
},
at: block_at.as_ref()
.map(|b| b.parse().map_err(|e| format!("Could not parse hash: {:?}", e))).transpose()?,
..Default::default()
})),
};