Skip to content

Commit

Permalink
fix: Rust (clippy) linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MaicoLeberle committed Jan 16, 2024
1 parent 9b6ce5c commit eaf0cef
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/sync/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,45 @@ use tracing::{debug, info, warn};
use crate::prelude::*;
use crate::storage::applydb::ApplyDB;

pub fn execute_phase1_validation(
ledger: &ApplyDB,
block: &MultiEraBlock<'_>,
) -> Result<(), WorkerError> {
let mut utxos = HashMap::new();
ledger
.resolve_inputs_for_block(block, &mut utxos)
.or_panic()?;

let mut utxos2 = UTxOs::new();

for (ref_, output) in utxos.iter() {
let txin = pallas::ledger::primitives::byron::TxIn::Variant0(
pallas::codec::utils::CborWrap((ref_.0, ref_.1 as u32)),
);

let key = MultiEraInput::Byron(
<Box<Cow<'_, pallas::ledger::primitives::byron::TxIn>>>::from(Cow::Owned(txin)),
);

let era = Era::try_from(output.0).or_panic()?;
let value = MultiEraOutput::decode(era, &output.1).or_panic()?;

utxos2.insert(key, value);
}

let env = ledger.get_active_pparams(block.slot()).or_panic()?;

for tx in block.txs().iter() {
let res = validate(tx, &utxos2, &env);

if let Err(err) = res {
warn!(?err, "validation error");
}
}

Ok(())
}

pub type UpstreamPort = gasket::messaging::tokio::InputPort<RollEvent>;

#[derive(Stage)]
Expand Down

0 comments on commit eaf0cef

Please sign in to comment.