Skip to content

Commit 20388f2

Browse files
committed
containers: improve partial types confinements
1 parent 920440e commit 20388f2

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/containers/partials.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::ops::{BitOr, BitOrAssign};
2323
use std::vec;
2424

2525
use amplify::confinement;
26-
use amplify::confinement::{Confined, MediumVec, U24};
26+
use amplify::confinement::{Confined, U24};
2727
use bp::seals::txout::CloseMethod;
2828
use commit_verify::mpc;
2929
use rgb::{OpId, Operation, OutputSeal, Transition, TransitionBundle, XAnchor};
@@ -160,7 +160,7 @@ impl BatchItem {
160160
)]
161161
pub struct Batch {
162162
pub main: BatchItem,
163-
pub blanks: MediumVec<BatchItem>,
163+
pub blanks: Confined<Vec<BatchItem>, 0, { U24 - 1 }>,
164164
}
165165

166166
impl StrictSerialize for Batch {}
@@ -181,7 +181,7 @@ impl IntoIterator for Batch {
181181
/// of finalized state transitions (under multiple contracts), packed into
182182
/// bundles, and anchored to a single layer 1 transaction.
183183
#[derive(Clone, PartialEq, Eq, Debug)]
184-
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
184+
#[derive(StrictType, StrictEncode, StrictDecode)]
185185
#[strict_type(lib = LIB_NAME_RGB_STD)]
186186
#[cfg_attr(
187187
feature = "serde",
@@ -190,8 +190,16 @@ impl IntoIterator for Batch {
190190
)]
191191
pub struct Fascia {
192192
pub anchor: XAnchor<mpc::MerkleBlock>,
193-
pub bundles: MediumVec<TransitionBundle>,
193+
pub bundles: Confined<Vec<TransitionBundle>, 1, U24>,
194194
}
195195

196+
impl StrictDumb for Fascia {
197+
fn strict_dumb() -> Self {
198+
Fascia {
199+
anchor: strict_dumb!(),
200+
bundles: confined_vec![strict_dumb!()],
201+
}
202+
}
203+
}
196204
impl StrictSerialize for Fascia {}
197205
impl StrictDeserialize for Fascia {}

src/persistence/inventory.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
2424
use std::error::Error;
2525
use std::ops::Deref;
2626

27-
use amplify::confinement::{self, Confined, MediumVec};
27+
use amplify::confinement::{self, Confined, MediumVec, U24};
2828
use bp::seals::txout::blind::SingleBlindSeal;
2929
use bp::seals::txout::CloseMethod;
3030
use bp::{Txid, Vout};
@@ -818,7 +818,7 @@ pub trait Inventory: Deref<Target = Self::Stash> {
818818
}
819819
}
820820
// Construct blank transitions
821-
let mut blanks = MediumVec::with_capacity(spent_state.len());
821+
let mut blanks = Confined::<Vec<_>, 0, { U24 - 1 }>::with_capacity(spent_state.len());
822822
for (id, opouts) in spent_state {
823823
let mut blank_builder = self.blank_builder(id, iface.clone())?;
824824
let mut outputs = Vec::with_capacity(opouts.len());

0 commit comments

Comments
 (0)