Skip to content

Commit

Permalink
sexp_from_bytes() -> node_from_bytes()
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiaMineJP committed Apr 24, 2024
1 parent 9109dc3 commit d55079c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions wasm/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use wasm_bindgen::prelude::wasm_bindgen;

use crate::flags::ALLOW_BACKREFS;
use crate::lazy_node::LazyNode;
use clvmr::serde::{node_from_bytes, node_from_bytes_backrefs, serialized_length_from_bytes};
use clvmr::serde::{
node_from_bytes as _node_from_bytes, node_from_bytes_backrefs, serialized_length_from_bytes,
};
use clvmr::Allocator;

#[wasm_bindgen]
Expand All @@ -12,12 +14,12 @@ pub fn serialized_length(program: &[u8]) -> Result<u64, String> {
}

#[wasm_bindgen]
pub fn sexp_from_bytes(b: &[u8], flag: u32) -> Result<LazyNode, String> {
pub fn node_from_bytes(b: &[u8], flag: u32) -> Result<LazyNode, String> {
let mut allocator = Allocator::new();
let deserializer = if (flag & ALLOW_BACKREFS) != 0 {
node_from_bytes_backrefs
} else {
node_from_bytes
_node_from_bytes
};
let node = deserializer(&mut allocator, b).map_err(|e| e.to_string())?;
Ok(LazyNode::new(Rc::new(allocator), node))
Expand Down

0 comments on commit d55079c

Please sign in to comment.