Clippy work towards rust 1.38 (#6219)

This commit is contained in:
Michael Vines
2019-10-02 18:04:18 -07:00
committed by GitHub
parent c06876eb3d
commit 13fc518268
12 changed files with 75 additions and 78 deletions

View File

@@ -141,7 +141,7 @@ impl<'a> StorageAccount<'a> {
};
self.account.set_state(storage_contract)
} else {
Err(InstructionError::AccountAlreadyInitialized)?
Err(InstructionError::AccountAlreadyInitialized)
}
}
@@ -157,7 +157,7 @@ impl<'a> StorageAccount<'a> {
};
self.account.set_state(storage_contract)
} else {
Err(InstructionError::AccountAlreadyInitialized)?
Err(InstructionError::AccountAlreadyInitialized)
}
}
@@ -234,7 +234,7 @@ impl<'a> StorageAccount<'a> {
segment_proofs.push(proof);
self.account.set_state(storage_contract)
} else {
Err(InstructionError::InvalidArgument)?
Err(InstructionError::InvalidArgument)
}
}
@@ -270,7 +270,7 @@ impl<'a> StorageAccount<'a> {
credits.current_epoch += total_validations;
self.account.set_state(storage_contract)
} else {
Err(InstructionError::InvalidArgument)?
Err(InstructionError::InvalidArgument)
}
}
@@ -360,7 +360,7 @@ impl<'a> StorageAccount<'a> {
self.account.set_state(storage_contract)
} else {
Err(InstructionError::InvalidArgument)?
Err(InstructionError::InvalidArgument)
}
}
@@ -380,9 +380,9 @@ impl<'a> StorageAccount<'a> {
} = &mut storage_contract
{
if owner.id != *account_owner {
Err(InstructionError::CustomError(
return Err(InstructionError::CustomError(
StorageError::InvalidOwner as u32,
))?
));
}
credits.update_epoch(clock.epoch);
@@ -397,9 +397,9 @@ impl<'a> StorageAccount<'a> {
} = &mut storage_contract
{
if owner.id != *account_owner {
Err(InstructionError::CustomError(
return Err(InstructionError::CustomError(
StorageError::InvalidOwner as u32,
))?
));
}
credits.update_epoch(clock.epoch);
let (num_validations, _total_proofs) = count_valid_proofs(&validations);
@@ -409,7 +409,7 @@ impl<'a> StorageAccount<'a> {
self.account.set_state(storage_contract)
} else {
Err(InstructionError::InvalidArgument)?
Err(InstructionError::InvalidArgument)
}
}
}
@@ -424,15 +424,16 @@ fn check_redeemable(
if rewards_pool.account.lamports < rewards {
Err(InstructionError::CustomError(
StorageError::RewardPoolDepleted as u32,
))?
))
} else {
if rewards >= 1 {
rewards_pool.account.lamports -= rewards;
owner.account.lamports += rewards;
//clear credits
credits.redeemable = 0;
}
Ok(())
}
if rewards >= 1 {
rewards_pool.account.lamports -= rewards;
owner.account.lamports += rewards;
//clear credits
credits.redeemable = 0;
}
Ok(())
}
pub fn create_rewards_pool() -> Account {

View File

@@ -22,13 +22,13 @@ pub fn process_instruction(
match bincode::deserialize(data).map_err(|_| InstructionError::InvalidInstructionData)? {
StorageInstruction::InitializeReplicatorStorage { owner } => {
if !rest.is_empty() {
Err(InstructionError::InvalidArgument)?;
return Err(InstructionError::InvalidArgument);
}
storage_account.initialize_replicator_storage(owner)
}
StorageInstruction::InitializeValidatorStorage { owner } => {
if !rest.is_empty() {
Err(InstructionError::InvalidArgument)?;
return Err(InstructionError::InvalidArgument);
}
storage_account.initialize_validator_storage(owner)
}
@@ -40,7 +40,7 @@ pub fn process_instruction(
} => {
if me_unsigned || rest.len() != 1 {
// This instruction must be signed by `me`
Err(InstructionError::InvalidArgument)?;
return Err(InstructionError::InvalidArgument);
}
let clock = sysvar::clock::from_keyed_account(&rest[0])?;
storage_account.submit_mining_proof(
@@ -54,14 +54,14 @@ pub fn process_instruction(
StorageInstruction::AdvertiseStorageRecentBlockhash { hash, segment } => {
if me_unsigned || rest.len() != 1 {
// This instruction must be signed by `me`
Err(InstructionError::InvalidArgument)?;
return Err(InstructionError::InvalidArgument);
}
let clock = sysvar::clock::from_keyed_account(&rest[0])?;
storage_account.advertise_storage_recent_blockhash(hash, segment, clock)
}
StorageInstruction::ClaimStorageReward => {
if rest.len() != 4 {
Err(InstructionError::InvalidArgument)?;
return Err(InstructionError::InvalidArgument);
}
let (clock, rest) = rest.split_at_mut(1);
let (rewards, rest) = rest.split_at_mut(1);
@@ -75,13 +75,13 @@ pub fn process_instruction(
}
StorageInstruction::ProofValidation { segment, proofs } => {
if rest.is_empty() {
Err(InstructionError::InvalidArgument)?;
return Err(InstructionError::InvalidArgument);
}
let (clock, rest) = rest.split_at_mut(1);
if me_unsigned || rest.is_empty() {
// This instruction must be signed by `me` and `rest` cannot be empty
Err(InstructionError::InvalidArgument)?;
return Err(InstructionError::InvalidArgument);
}
let me_id = storage_account.id;
let clock = sysvar::clock::from_keyed_account(&clock[0])?;