Merge pull request #7357 from paritytech/unwrap-or
Avoid using ok_or with allocated argument
This commit is contained in:
commit
6f516607a1
@ -58,7 +58,7 @@ impl ValidatorContract {
|
|||||||
let client = self.client.read().clone();
|
let client = self.client.read().clone();
|
||||||
Box::new(move |a, d| client.as_ref()
|
Box::new(move |a, d| client.as_ref()
|
||||||
.and_then(Weak::upgrade)
|
.and_then(Weak::upgrade)
|
||||||
.ok_or("No client!".into())
|
.ok_or_else(|| "No client!".into())
|
||||||
.and_then(|c| {
|
.and_then(|c| {
|
||||||
match c.as_full_client() {
|
match c.as_full_client() {
|
||||||
Some(c) => c.transact_contract(a, d)
|
Some(c) => c.transact_contract(a, d)
|
||||||
|
@ -138,7 +138,7 @@ impl ValidatorSet for Multi {
|
|||||||
}
|
}
|
||||||
*self.block_number.write() = Box::new(move |id| client
|
*self.block_number.write() = Box::new(move |id| client
|
||||||
.upgrade()
|
.upgrade()
|
||||||
.ok_or("No client!".into())
|
.ok_or_else(|| "No client!".into())
|
||||||
.and_then(|c| c.block_number(id).ok_or("Unknown block".into())));
|
.and_then(|c| c.block_number(id).ok_or("Unknown block".into())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ impl ValidatorSet for ValidatorSafeContract {
|
|||||||
let client = self.client.read().clone();
|
let client = self.client.read().clone();
|
||||||
Box::new(move |addr, data| client.as_ref()
|
Box::new(move |addr, data| client.as_ref()
|
||||||
.and_then(Weak::upgrade)
|
.and_then(Weak::upgrade)
|
||||||
.ok_or("No client!".into())
|
.ok_or_else(|| "No client!".into())
|
||||||
.and_then(|c| {
|
.and_then(|c| {
|
||||||
match c.as_full_client() {
|
match c.as_full_client() {
|
||||||
Some(c) => c.call_contract(id, addr, data),
|
Some(c) => c.call_contract(id, addr, data),
|
||||||
|
@ -121,7 +121,7 @@ mod server {
|
|||||||
// Attempt to sign in the engine signer.
|
// Attempt to sign in the engine signer.
|
||||||
let password = deps.accounts_passwords.iter()
|
let password = deps.accounts_passwords.iter()
|
||||||
.find(|p| deps.account_provider.sign(account.clone(), Some((*p).clone()), Default::default()).is_ok())
|
.find(|p| deps.account_provider.sign(account.clone(), Some((*p).clone()), Default::default()).is_ok())
|
||||||
.ok_or(format!("No valid password for the secret store node account {}", account))?;
|
.ok_or_else(|| format!("No valid password for the secret store node account {}", account))?;
|
||||||
Arc::new(ethcore_secretstore::KeyStoreNodeKeyPair::new(deps.account_provider, account, password.clone())
|
Arc::new(ethcore_secretstore::KeyStoreNodeKeyPair::new(deps.account_provider, account, password.clone())
|
||||||
.map_err(|e| format!("{}", e))?)
|
.map_err(|e| format!("{}", e))?)
|
||||||
},
|
},
|
||||||
|
@ -111,7 +111,7 @@ impl CachedContract {
|
|||||||
let do_call = |a, d| future::done(
|
let do_call = |a, d| future::done(
|
||||||
self.client
|
self.client
|
||||||
.upgrade()
|
.upgrade()
|
||||||
.ok_or("Calling contract without client".into())
|
.ok_or_else(|| "Calling contract without client".into())
|
||||||
.and_then(|c| c.call_contract(BlockId::Latest, a, d)));
|
.and_then(|c| c.call_contract(BlockId::Latest, a, d)));
|
||||||
contract.check_permissions(do_call, address, document.clone())
|
contract.check_permissions(do_call, address, document.clone())
|
||||||
.map_err(|err| Error::Internal(err))
|
.map_err(|err| Error::Internal(err))
|
||||||
|
@ -258,7 +258,7 @@ impl<T> SessionImpl<T> where T: SessionTransport {
|
|||||||
let admin_public = self.core.admin_public.as_ref().cloned().ok_or(Error::ConsensusUnreachable)?;
|
let admin_public = self.core.admin_public.as_ref().cloned().ok_or(Error::ConsensusUnreachable)?;
|
||||||
|
|
||||||
// key share version is required on ShareAdd master node
|
// key share version is required on ShareAdd master node
|
||||||
let key_share = self.core.key_share.as_ref().ok_or(Error::KeyStorage("key share is not found on master node".into()))?;
|
let key_share = self.core.key_share.as_ref().ok_or_else(|| Error::KeyStorage("key share is not found on master node".into()))?;
|
||||||
let key_version = key_share.version(&version).map_err(|e| Error::KeyStorage(e.into()))?;
|
let key_version = key_share.version(&version).map_err(|e| Error::KeyStorage(e.into()))?;
|
||||||
|
|
||||||
// old nodes set is all non-isolated owners of version holders
|
// old nodes set is all non-isolated owners of version holders
|
||||||
|
@ -188,7 +188,7 @@ impl<T> SessionImpl<T> where T: SessionTransport {
|
|||||||
let is_consensus_pre_established = data.shares_to_move.is_some();
|
let is_consensus_pre_established = data.shares_to_move.is_some();
|
||||||
if !is_consensus_pre_established {
|
if !is_consensus_pre_established {
|
||||||
let shares_to_move_reversed = shares_to_move_reversed.ok_or(Error::InvalidMessage)?;
|
let shares_to_move_reversed = shares_to_move_reversed.ok_or(Error::InvalidMessage)?;
|
||||||
let key_share = self.core.key_share.as_ref().ok_or(Error::KeyStorage("key share is not found on master node".into()))?;
|
let key_share = self.core.key_share.as_ref().ok_or_else(|| Error::KeyStorage("key share is not found on master node".into()))?;
|
||||||
check_shares_to_move(&self.core.meta.self_node_id, &shares_to_move_reversed, Some(&key_share.id_numbers))?;
|
check_shares_to_move(&self.core.meta.self_node_id, &shares_to_move_reversed, Some(&key_share.id_numbers))?;
|
||||||
|
|
||||||
let old_set_signature = old_set_signature.ok_or(Error::InvalidMessage)?;
|
let old_set_signature = old_set_signature.ok_or(Error::InvalidMessage)?;
|
||||||
|
@ -149,7 +149,7 @@ impl PersistentKeyStorage {
|
|||||||
pub fn new(config: &ServiceConfiguration) -> Result<Self, Error> {
|
pub fn new(config: &ServiceConfiguration) -> Result<Self, Error> {
|
||||||
let mut db_path = PathBuf::from(&config.data_path);
|
let mut db_path = PathBuf::from(&config.data_path);
|
||||||
db_path.push("db");
|
db_path.push("db");
|
||||||
let db_path = db_path.to_str().ok_or(Error::Database("Invalid secretstore path".to_owned()))?;
|
let db_path = db_path.to_str().ok_or_else(|| Error::Database("Invalid secretstore path".to_owned()))?;
|
||||||
|
|
||||||
let db = Database::open_default(&db_path)?;
|
let db = Database::open_default(&db_path)?;
|
||||||
let db = upgrade_db(db)?;
|
let db = upgrade_db(db)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user