Skip to content

Commit

Permalink
persistence: complete fascia consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 24, 2023
1 parent e8ba265 commit ce5ee6b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/persistence/hoard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub enum ConsumeError {

#[from]
MergeReveal(MergeRevealError),

/// bundle {1} for contract {0} contains invalid transitioon input map
#[display(doc_comments)]
InvalidBundle(ContractId, BundleId),
}

impl From<Infallible> for InventoryError<Infallible> {
Expand Down
17 changes: 9 additions & 8 deletions src/persistence/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,21 +355,22 @@ pub trait Inventory: Deref<Target = Self::Stash> {
///
/// Must be called before the consignment is created, when witness
/// transaction is not yet mined.
fn consume(&mut self, _fascia: Fascia) -> Result<(), InventoryError<Self::Error>> {
todo!();
/*
fn consume(&mut self, fascia: Fascia) -> Result<(), InventoryError<Self::Error>> {
let witness_id = fascia.anchor.witness_id();
unsafe { self.consume_anchor(fascia.anchor)? };
for bundle in fascia.bundles {
let ids1 = bundle.known_transitions.keys().copied().collect::<BTreeSet<_>>();
for (contract_id, bundle) in fascia.bundles {
let ids1 = bundle
.known_transitions
.keys()
.copied()
.collect::<BTreeSet<_>>();
let ids2 = bundle.input_map.values().copied().collect::<BTreeSet<_>>();
if !ids1.is_subset(&ids2) {
return Err(ConsumeError::InvalidBundle(contract_id, bundle.bundle_id()).into());
}
unsafe { self.consume_bundle(fascia.contract_id, bundle, witness_id)? };
unsafe { self.consume_bundle(contract_id, bundle, witness_id)? };
}
Ok(())
*/
}

#[doc(hidden)]
Expand Down

0 comments on commit ce5ee6b

Please sign in to comment.