Skip to content

Commit

Permalink
Fix compilation without 'parallel' feature
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Zwolinski <[email protected]>
  • Loading branch information
zvolin committed Oct 12, 2022
1 parent 60865ab commit d1b7a8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ cuda = [ "snarkvm-algorithms/cuda" ]
parameters_no_std_out = [ "snarkvm-parameters/no_std_out" ]
parallel = [
"rayon",
"snarkvm-algorithms/parallel",
"snarkvm-compiler/parallel",
"snarkvm-fields/parallel",
"snarkvm-utilities/parallel"
Expand All @@ -124,6 +125,7 @@ noconfig = [ ]
path = "./algorithms"
version = "0.9.0"
optional = true
default-features = false

[dependencies.snarkvm-circuit]
path = "./circuit"
Expand Down Expand Up @@ -168,6 +170,7 @@ optional = true
[dependencies.snarkvm-compiler]
path = "./vm/compiler"
version = "0.9.0"
default-features = false

[dependencies.anyhow]
version = "1.0.64"
Expand Down
12 changes: 10 additions & 2 deletions vm/compiler/src/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ impl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P> {
ledger.block_tree.append(&hashes)?;

// Safety check the existence of every block.
(0..=latest_height).into_par_iter().try_for_each(|height| {
#[cfg(feature = "parallel")]
let heights_iter = (0..=latest_height).into_par_iter();
#[cfg(not(feature = "parallel"))]
let mut heights_iter = (0..=latest_height).into_iter();
heights_iter.try_for_each(|height| {
ledger.get_block(height)?;
Ok::<_, Error>(())
})?;
Expand Down Expand Up @@ -467,7 +471,11 @@ impl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P> {
}

// Ensure each transaction is well-formed and unique.
if !block.transactions().par_iter().all(|(_, transaction)| self.check_transaction(transaction).is_ok()) {
#[cfg(feature = "parallel")]
let transactions_iter = block.transactions().par_iter();
#[cfg(not(feature = "parallel"))]
let mut transactions_iter = block.transactions().iter();
if !transactions_iter.all(|(_, transaction)| self.check_transaction(transaction).is_ok()) {
bail!("Invalid transaction found in the transactions list");
}

Expand Down

0 comments on commit d1b7a8f

Please sign in to comment.