Skip to content

Commit

Permalink
vm: fix ContractState API
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 26, 2024
1 parent d3235cb commit c41cac2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/validation/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ impl<'consignment, 'resolver, C: ConsignmentApi, R: ResolveWitness>
///
/// When a failure detected, validation is not stopped; the failure is
/// logged into the status object, but the validation continues for the
/// rest of the consignment data. This can help it debugging and
/// detecting all problems with the consignment.
/// rest of the consignment data. This can help to debug and detect all
/// problems with the consignment.
pub fn validate(consignment: &'consignment C, resolver: &'resolver R, testnet: bool) -> Status {
let mut validator = Validator::init(consignment, resolver);
// If the network mismatches there is no point in validating the contract since
Expand Down Expand Up @@ -277,7 +277,7 @@ impl<'consignment, 'resolver, C: ConsignmentApi, R: ResolveWitness>
// utilize queue to keep the track of the upstream (ancestor) nodes and make
// sure that ve have validated each one of them up to genesis. The graph is
// valid when each of its nodes and each of its edges is valid, i.e. when all
// individual nodes has passed validation against the schema (we track
// individual nodes have passed validation against the schema (we track
// that fact with `validation_index`) and each of the operation ancestor state
// change to a given operation is valid against the schema + committed
// into bitcoin transaction graph with proper anchor. That is what we are
Expand Down
18 changes: 9 additions & 9 deletions src/vm/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,30 +148,30 @@ impl GlobalOrd {
}
}

// TODO: Support unspent
pub trait ContractState {
fn global(&self, ty: GlobalStateType)
-> Option<LargeOrdMap<GlobalOrd, impl Borrow<DataState>>>;
fn global(
&self,
ty: GlobalStateType,
) -> Option<&LargeOrdMap<GlobalOrd, impl Borrow<DataState>>>;

fn rights(&self, outpoint: XOutpoint, ty: AssignmentType, unspent: bool) -> Option<u32>;
fn rights(&self, outpoint: XOutpoint, ty: AssignmentType) -> u32;

fn fungible(
&self,
outpoint: XOutpoint,
ty: AssignmentType,
unspent: bool,
) -> Option<impl DoubleEndedIterator<Item = FungibleState>>;
) -> impl DoubleEndedIterator<Item = FungibleState>;

fn data(
&self,
outpoint: XOutpoint,
ty: AssignmentType,
unspent: bool,
) -> Option<impl DoubleEndedIterator<Item = impl Borrow<DataState>>>;
) -> impl DoubleEndedIterator<Item = impl Borrow<DataState>>;

fn attach(
&self,
outpoint: XOutpoint,
ty: AssignmentType,
unspent: bool,
) -> Option<impl DoubleEndedIterator<Item = impl Borrow<RevealedAttach>>>;
) -> impl DoubleEndedIterator<Item = impl Borrow<RevealedAttach>>;
}

0 comments on commit c41cac2

Please sign in to comment.