Skip to content

Commit

Permalink
Remove LazyMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Sep 11, 2023
1 parent 5d2dbf3 commit 749088e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 91 deletions.
88 changes: 0 additions & 88 deletions src/models/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,70 +14,6 @@ mod address;
#[cfg(test)]
mod tests;

/// Lazy-loaded message model.
#[derive(Debug, Clone, Eq)]
#[repr(transparent)]
pub struct LazyMessage(Cell);

impl LazyMessage {
/// Serializes the provided data and returns the typed wrapper around it.
pub fn new(data: &Message) -> Result<Self, Error> {
let mut builder = CellBuilder::new();
let finalizer = &mut Cell::default_finalizer();
ok!(data.store_into(&mut builder, finalizer));
Ok(Self::from_raw(ok!(builder.build_ext(finalizer))))
}

/// Wraps the cell in a typed wrapper.
#[inline]
pub fn from_raw(cell: Cell) -> Self {
Self(cell)
}

/// Converts into the underlying cell.
#[inline]
pub fn into_inner(self) -> Cell {
self.0
}

/// Returns the underlying cell.
#[inline]
pub fn inner(&self) -> &Cell {
&self.0
}

/// Loads inner data from cell.
pub fn load(&self) -> Result<Message<'_>, Error> {
self.0.as_ref().parse::<Message>()
}
}

impl PartialEq for LazyMessage {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.0.as_ref() == other.0.as_ref()
}
}

impl PartialEq<Cell> for LazyMessage {
#[inline]
fn eq(&self, other: &Cell) -> bool {
self.0.as_ref() == other.as_ref()
}
}

impl Store for LazyMessage {
fn store_into(&self, builder: &mut CellBuilder, _: &mut dyn Finalizer) -> Result<(), Error> {
builder.store_reference(self.0.clone())
}
}

impl<'a> Load<'a> for LazyMessage {
fn load_from(slice: &mut CellSlice<'a>) -> Result<Self, Error> {
slice.load_reference_cloned().map(Self)
}
}

/// Blockchain message (with body as slice).
pub type Message<'a> = BaseMessage<MsgInfo, CellSlice<'a>>;

Expand Down Expand Up @@ -306,30 +242,6 @@ impl<'a> LoadBody<'a> for CellSliceParts {
}
}

// struct RelaxedMessageImpl;

// impl MessageImpl for RelaxedMessageImpl {
// type Info = RelaxedMsgInfo;
// type Body<'a> = CellSlice<'a>;

// #[inline]
// fn compute_info_size(info: &Self::Info) -> (u16, u8) {
// info.size()
// }
// }

// struct RelaxedOwnedMessageImpl;

// impl MessageImpl for RelaxedOwnedMessageImpl {
// type Info = RelaxedMsgInfo;
// type Body<'a> = CellSliceParts;

// #[inline]
// fn compute_info_size(info: &Self::Info) -> (u16, u8) {
// info.size()
// }
// }

struct SliceOrCell<T> {
to_cell: bool,
value: T,
Expand Down
7 changes: 4 additions & 3 deletions src/models/vm/out_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use bitflags::bitflags;
use crate::cell::*;
use crate::error::Error;
use crate::models::currency::CurrencyCollection;
use crate::models::message::LazyMessage;
use crate::models::message::OwnedRelaxedMessage;
use crate::models::Lazy;

/// Out actions list reverse iterator.
pub struct OutActionsRevIter<'a> {
Expand Down Expand Up @@ -148,7 +149,7 @@ pub enum OutAction {
/// Behavior flags.
mode: SendMsgFlags,
/// A cell with a message.
out_msg: LazyMessage,
out_msg: Lazy<OwnedRelaxedMessage>,
},
/// Creates an output action that would change this smart contract code
/// to that given by cell.
Expand Down Expand Up @@ -237,7 +238,7 @@ impl<'a> Load<'a> for OutAction {
Ok(match tag {
Self::TAG_SEND_MSG => Self::SendMsg {
mode: ok!(SendMsgFlags::load_from(slice)),
out_msg: ok!(LazyMessage::load_from(slice)),
out_msg: ok!(Lazy::load_from(slice)),
},
Self::TAG_SET_CODE => Self::SetCode {
new_code: ok!(slice.load_reference_cloned()),
Expand Down

0 comments on commit 749088e

Please sign in to comment.