Skip to content

Commit

Permalink
Merge pull request fedimint#5891 from elsirion/2024-08-redundant-argu…
Browse files Browse the repository at this point in the history
…ment

chore: remove redundant arguments
  • Loading branch information
tvolk131 authored Aug 20, 2024
2 parents a888a97 + 5109b5a commit 9287bf0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
22 changes: 5 additions & 17 deletions fedimint-core/src/core/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ pub trait IServerModule: Debug {
// Use this function to parallelise stateless cryptographic verification of
// inputs across a transaction. All inputs of a transaction are verified
// before any input is processed.
fn verify_input(
&self,
input: &DynInput,
module_instance_id: ModuleInstanceId,
) -> Result<(), DynInputError>;
fn verify_input(&self, input: &DynInput) -> Result<(), DynInputError>;

/// Try to spend a transaction input. On success all necessary updates will
/// be part of the database transaction. On failure (e.g. double spend)
Expand All @@ -69,7 +65,6 @@ pub trait IServerModule: Debug {
&'a self,
dbtx: &mut DatabaseTransaction<'c>,
input: &'b DynInput,
module_instance_id: ModuleInstanceId,
) -> Result<InputMeta, DynInputError>;

/// Try to create an output (e.g. issue notes, peg-out BTC, …). On success
Expand All @@ -85,7 +80,6 @@ pub trait IServerModule: Debug {
dbtx: &mut DatabaseTransaction<'a>,
output: &DynOutput,
out_point: OutPoint,
module_instance_id: ModuleInstanceId,
) -> Result<TransactionItemAmount, DynOutputError>;

/// Retrieve the current status of the output. Depending on the module this
Expand Down Expand Up @@ -178,19 +172,15 @@ where
// Use this function to parallelise stateless cryptographic verification of
// inputs across a transaction. All inputs of a transaction are verified
// before any input is processed.
fn verify_input(
&self,
input: &DynInput,
module_instance_id: ModuleInstanceId,
) -> Result<(), DynInputError> {
fn verify_input(&self, input: &DynInput) -> Result<(), DynInputError> {
<Self as ServerModule>::verify_input(
self,
input
.as_any()
.downcast_ref::<<<Self as ServerModule>::Common as ModuleCommon>::Input>()
.expect("incorrect input type passed to module plugin"),
)
.map_err(|v| DynInputError::from_typed(module_instance_id, v))
.map_err(|v| DynInputError::from_typed(input.module_instance_id(), v))
}

/// Try to spend a transaction input. On success all necessary updates will
Expand All @@ -201,7 +191,6 @@ where
&'a self,
dbtx: &mut DatabaseTransaction<'c>,
input: &'b DynInput,
module_instance_id: ModuleInstanceId,
) -> Result<InputMeta, DynInputError> {
<Self as ServerModule>::process_input(
self,
Expand All @@ -213,7 +202,7 @@ where
)
.await
.map(Into::into)
.map_err(|v| DynInputError::from_typed(module_instance_id, v))
.map_err(|v| DynInputError::from_typed(input.module_instance_id(), v))
}

/// Try to create an output (e.g. issue notes, peg-out BTC, …). On success
Expand All @@ -229,7 +218,6 @@ where
dbtx: &mut DatabaseTransaction<'a>,
output: &DynOutput,
out_point: OutPoint,
module_instance_id: ModuleInstanceId,
) -> Result<TransactionItemAmount, DynOutputError> {
<Self as ServerModule>::process_output(
self,
Expand All @@ -241,7 +229,7 @@ where
out_point,
)
.await
.map_err(|v| DynOutputError::from_typed(module_instance_id, v))
.map_err(|v| DynOutputError::from_typed(output.module_instance_id(), v))
}

/// Retrieve the current status of the output. Depending on the module this
Expand Down
4 changes: 1 addition & 3 deletions fedimint-server/src/consensus/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub async fn process_transaction_with_dbtx(
.try_for_each(|input| {
modules
.get_expect(input.module_instance_id())
.verify_input(&input, input.module_instance_id())
.verify_input(&input)
})
.map_err(|_| TransactionError::InvalidWitnessLength)?;

Expand All @@ -44,7 +44,6 @@ pub async fn process_transaction_with_dbtx(
.process_input(
&mut dbtx.to_ref_with_prefix_module_id(input.module_instance_id()),
input,
input.module_instance_id(),
)
.await
.map_err(TransactionError::Input)?;
Expand All @@ -64,7 +63,6 @@ pub async fn process_transaction_with_dbtx(
&mut dbtx.to_ref_with_prefix_module_id(output.module_instance_id()),
output,
OutPoint { txid, out_idx },
output.module_instance_id(),
)
.await
.map_err(TransactionError::Output)?;
Expand Down

0 comments on commit 9287bf0

Please sign in to comment.