Skip to content

Commit

Permalink
vm: use SmallBlob for global data
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 15, 2024
1 parent 942035f commit 90e76b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/vm/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use std::num::NonZeroU32;
use std::rc::Rc;

use amplify::confinement;
use amplify::confinement::SmallBlob;
use amplify::num::u24;
use bp::seals::txout::{CloseMethod, ExplicitSeal, VerifyError, Witness};
use bp::{dbc, Tx, Txid};
Expand Down Expand Up @@ -571,7 +572,7 @@ impl GlobalOrd {
}

pub trait GlobalStateIter {
type Data: Borrow<State>;
type Data: Borrow<SmallBlob>;
fn size(&mut self) -> u24;
fn prev(&mut self) -> Option<(GlobalOrd, Self::Data)>;
fn last(&mut self) -> Option<(GlobalOrd, Self::Data)>;
Expand Down Expand Up @@ -632,7 +633,7 @@ impl<I: GlobalStateIter> GlobalContractState<I> {
/// Retrieves global state data located `depth` items back from the most
/// recent global state value. Ensures that the global state ordering is
/// consensus-based.
pub fn nth(&mut self, depth: u24) -> Option<impl Borrow<State> + '_> {
pub fn nth(&mut self, depth: u24) -> Option<impl Borrow<SmallBlob> + '_> {

Check warning on line 636 in src/vm/contract.rs

View check run for this annotation

Codecov / codecov/patch

src/vm/contract.rs#L636

Added line #L636 was not covered by tests
if depth >= self.iter.size() {
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vm/op_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl<S: ContractStateAccess> InstructionSet for ContractOp<S> {
let Some(state) = global.nth(index) else {
fail!()
};
regs.set_s(*reg_s, Some(&state.borrow().value));
regs.set_s(*reg_s, Some(state.borrow()));

Check warning on line 292 in src/vm/op_contract.rs

View check run for this annotation

Codecov / codecov/patch

src/vm/op_contract.rs#L292

Added line #L292 was not covered by tests
}
ContractOp::LdM(type_id, reg) => {
let Some(meta) = context.op_info.metadata.get(type_id) else {
Expand Down

0 comments on commit 90e76b3

Please sign in to comment.