Skip to content

Commit

Permalink
containers: make bindle content immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Feb 26, 2024
1 parent a22008e commit 0a9c92e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
6 changes: 1 addition & 5 deletions src/containers/bindle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use std::collections::BTreeMap;
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::ops::{Deref, DerefMut};
use std::ops::Deref;
use std::str::FromStr;

use amplify::confinement::{self, Confined, TinyVec, U24 as U24MAX};
Expand Down Expand Up @@ -157,10 +157,6 @@ impl<C: BindleContent> Deref for Bindle<C> {
fn deref(&self) -> &Self::Target { &self.data }
}

impl<C: BindleContent> DerefMut for Bindle<C> {
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.data }
}

impl<C: BindleContent> From<C> for Bindle<C> {
fn from(data: C) -> Self { Bindle::new(data) }
}
Expand Down
18 changes: 10 additions & 8 deletions src/persistence/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ use strict_encoding::TypeName;

use crate::accessors::{BundleExt, MergeRevealError, RevealError};
use crate::containers::{
Batch, Bindle, BuilderSeal, Cert, Consignment, ContentId, Contract, Fascia, Terminal,
TerminalSeal, Transfer, TransitionInfo,
Batch, Bindle, BindleContent, BuilderSeal, Cert, Consignment, ContentId, Contract, Fascia,
Terminal, TerminalSeal, Transfer, TransitionInfo,
};
use crate::interface::{
BuilderError, ContractIface, Iface, IfaceId, IfaceImpl, IfacePair, IfaceWrapper,
Expand Down Expand Up @@ -595,14 +595,11 @@ pub trait Inventory: Deref<Target = Self::Stash> {
contract_id: ContractId,
outputs: impl AsRef<[XOutputSeal]>,
secret_seals: impl AsRef<[XChain<SecretSeal>]>,
) -> Result<
Bindle<Transfer>,
ConsignerError<Self::Error, <<Self as Deref>::Target as Stash>::Error>,
> {
) -> Result<Transfer, ConsignerError<Self::Error, <<Self as Deref>::Target as Stash>::Error>>
{
let mut consignment = self.consign(contract_id, outputs, secret_seals)?;
consignment.transfer = true;
Ok(consignment.into())
// TODO: Add known sigs to the bindle
Ok(consignment)
}

fn consign<const TYPE: bool>(
Expand Down Expand Up @@ -704,6 +701,11 @@ pub trait Inventory: Deref<Target = Self::Stash> {
Ok(consignment)
}

fn bindle<C: BindleContent>(&self, content: C) -> Bindle<C> {
// TODO: Add known sigs to the bindle
Bindle::from(content)
}

/// Composes a batch of state transitions updating state for the provided
/// set of previous outputs, satisfying requirements of the invoice, paying
/// the change back and including the necessary blank state transitions.
Expand Down

0 comments on commit 0a9c92e

Please sign in to comment.