Skip to content

Commit d89066a

Browse files
author
Denis K
authored
Merge pull request #38 from tonlabs/fix_for_types
fix for types
2 parents cd202db + d42d50e commit d89066a

File tree

6 files changed

+19
-20
lines changed

6 files changed

+19
-20
lines changed

ton-node-se/ton_node/src/node_engine/block_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ struct BlockData {
5454
impl BlockData {
5555
fn insert_serialized_in_msg(&mut self, msg_cell: &Cell, fees: &ImportFees ) -> Result<()> {
5656
let mut in_msg_dscr = self.block_extra.read_in_msg_descr()?;
57-
in_msg_dscr.insert_serialized(&msg_cell.repr_hash().write_to_new_cell()?.into(), &msg_cell.into(), fees)?;
57+
in_msg_dscr.insert_serialized(&msg_cell.repr_hash().serialize()?.into(), &msg_cell.into(), fees)?;
5858
self.block_extra.write_in_msg_descr(&in_msg_dscr)
5959
}
6060

6161
fn insert_serialized_out_msg(&mut self, msg_cell: &Cell, exported: &CurrencyCollection) -> Result<()> {
6262
let mut out_msg_descr = self.block_extra.read_out_msg_descr()?;
63-
out_msg_descr.insert_serialized(&msg_cell.repr_hash().write_to_new_cell()?.into(), &msg_cell.into(), exported)?;
63+
out_msg_descr.insert_serialized(&msg_cell.repr_hash().serialize()?.into(), &msg_cell.into(), exported)?;
6464
self.block_extra.write_out_msg_descr(&out_msg_descr)
6565
}
6666
}

ton-node-se/ton_node/src/node_engine/blocks_finality.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::io::{ErrorKind, Read, Seek, Write};
99
use std::path::PathBuf;
1010
use ton_block::{InMsg, OutMsg, AccountStatus, ExtOutMessageHeader, MsgEnvelope};
1111
use ton_block::{HashmapAugType, BlkPrevInfo, Deserializable, ShardIdent};
12-
use ton_types::{UInt256, deserialize_tree_of_cells, BagOfCells, BuilderData};
12+
use ton_types::{UInt256, deserialize_tree_of_cells, BagOfCells};
1313

1414
#[cfg(test)]
1515
#[path = "../../../tonos-se-tests/unit/test_block_finality.rs"]
@@ -102,7 +102,7 @@ debug!("FINBLK {:?}", hashes);
102102
hash: sb.block_hash.clone(),
103103
};
104104
let mut shard = vec![];
105-
BagOfCells::with_root(&sb.shard_state.write_to_new_cell()?.into())
105+
BagOfCells::with_root(&sb.shard_state.serialize()?)
106106
.write_to(&mut shard, false)?;
107107
// save shard state
108108
self.shard_state_storage.save_serialized_shardstate_ex(
@@ -352,9 +352,9 @@ debug!("FINBLK {:?}", hashes);
352352
if !is_sync {
353353
if let Some(db) = self.db.clone() {
354354

355-
// let block_root = block.write_to_new_cell()?.into();
356-
// let state_root = shard_state.write_to_new_cell()?.into();
357-
// let block_info_root = block.read_info()?.write_to_new_cell()?;
355+
// let block_root = block.serialize()?;
356+
// let state_root = shard_state.serialize()?;
357+
// let block_info_root = block.read_info()?.serialize()?;
358358
// let block_info_cells = BagOfCells::with_root(&block_info_root.into())
359359
// .withdraw_cells();
360360

@@ -594,7 +594,7 @@ debug!(target: "node", "PUT-BLOCK-HASH {:?}", sb.block_hash);
594594
/// get number of last finalized shard
595595
fn get_last_finality_shard_hash(&self) -> NodeResult<(u64, UInt256)> {
596596
// TODO avoid serilization there
597-
let cell: Cell = self.last_finalized_block.shard_state.write_to_new_cell()?.into();
597+
let cell = self.last_finalized_block.shard_state.serialize()?;
598598

599599
Ok((self.last_finalized_block.seq_no, cell.repr_hash()))
600600
}
@@ -719,9 +719,8 @@ impl ShardBlock {
719719
// Test-lite-client requires hash od unsigned block
720720
// TODO will to think, how to do better
721721
let mut block_data = vec![];
722-
let mut builder = BuilderData::new();
723-
sblock.block().write_to(&mut builder).unwrap(); // TODO process result
724-
let bag = BagOfCells::with_root(&builder.into());
722+
let cell = sblock.block().serialize().unwrap(); // TODO process result
723+
let bag = BagOfCells::with_root(&cell);
725724
bag.write_to(&mut block_data, false).unwrap(); // TODO process result
726725

727726
let mut hasher = Sha256::new();
@@ -747,7 +746,7 @@ impl ShardBlock {
747746
buf.append(&mut self.block_hash.as_slice().to_vec());
748747
buf.append(&mut self.file_hash.as_slice().to_vec());
749748

750-
BagOfCells::with_root(&self.shard_state.write_to_new_cell()?.into())
749+
BagOfCells::with_root(&self.shard_state.serialize()?)
751750
.write_to(&mut buf, false)?;
752751

753752
let mut block_buf = Vec::new();
@@ -852,7 +851,7 @@ pub(crate) fn generate_block_with_seq_no(shard_ident: ShardIdent, seq_no: u32, p
852851
let mut outmsg2 = Message::with_ext_out_header(eomh);
853852
*outmsg2.body_mut() = Some(SliceData::new(vec![0x02;120]));
854853

855-
let tr_cell: Cell = transaction.write_to_new_cell().unwrap().into();
854+
let tr_cell = transaction.serialize().unwrap();
856855

857856
let out_msg1 = OutMsg::new(
858857
&MsgEnvelope::with_message_and_fee(&outmsg1, 9u32.into()).unwrap(),

ton-node-se/ton_node/src/node_engine/file_based_storage.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ impl ShardStateStorage for FileBasedStorage {
333333
let (mut shard_path, _blocks_path, _tr_dir) = Self::create_default_shard_catalog(shard_dir, &self.shard_ident)?;
334334
shard_path.push("shard_state.block");
335335

336-
let builder = shard_state.write_to_new_cell()?;
336+
let cell = shard_state.serialize()?;
337337
let mut file = File::create(shard_path.as_path())?;
338-
serialize_tree_of_cells(&builder.into(), &mut file)?;
338+
serialize_tree_of_cells(&cell, &mut file)?;
339339
file.flush()?;
340340
Ok(())
341341
}
@@ -364,8 +364,8 @@ impl ShardStateStorage for FileBasedStorage {
364364
if shard_data.is_some() {
365365
file.write_all(shard_data.unwrap().as_slice())?;
366366
} else {
367-
let builder = shard_state.write_to_new_cell()?;
368-
serialize_tree_of_cells(&builder.into(), &mut file)?;
367+
let cell = shard_state.serialize()?;
368+
serialize_tree_of_cells(&cell, &mut file)?;
369369
}
370370
file.flush()?;
371371

ton-node-se/ton_node/src/node_engine/messages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ info!(target: "profiler",
461461

462462
fn get_out_msgs_from_transaction(shard_id: &ShardIdent, transaction: &Transaction, reimport: &InMsg) -> NodeResult<Vec<OutMsg>> {
463463
let mut res = vec![];
464-
let tr_cell: Cell = transaction.write_to_new_cell()?.into();
464+
let tr_cell = transaction.serialize()?;
465465
transaction.iterate_out_msgs(|ref msg| {
466466
res.push(if msg.is_internal() {
467467
if shard_id.contains_address(&msg.dst().unwrap())? {

ton-node-se/ton_node/src/node_engine/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl StubReceiver {
304304
);
305305

306306
*msg.body_mut() = Some(Self::create_transfer_int_header(workchain_id, src, dst, value)
307-
.write_to_new_cell()
307+
.serialize()
308308
.unwrap()
309309
.into()
310310
);

ton-node-se/ton_node/src/node_engine/ton_node_handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ time.push(now.elapsed().as_micros());
10301030
self.sync_limit.store(0, AtomicOrdering::SeqCst);
10311031
}
10321032

1033-
/// stop synchronization
1033+
/// start synchronization
10341034
fn start_sync(&self) -> bool {
10351035
let res = self.is_synchronize.compare_exchange(false, true, AtomicOrdering::SeqCst, AtomicOrdering::SeqCst);
10361036
info!(target: "node", "Start synchronization = {}!", res.is_ok());

0 commit comments

Comments
 (0)