From 4292bc7fdf5f2d889c2e57ba35a5b37811553d87 Mon Sep 17 00:00:00 2001 From: Tonjen Date: Wed, 20 Oct 2021 16:47:48 +0000 Subject: [PATCH] Automatic project update --- Cargo.toml | 2 +- src/master.rs | 18 ++++++++---------- src/shard.rs | 2 +- src/types.rs | 7 ++++--- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5d2fa08..d6e9ea6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ edition = "2018" build = "build.rs" name = "ton_block" -version = "1.7.26" +version = "1.7.27" [target.'cfg(target_arch = "wasm32")'.dependencies] clear_on_drop = { version = "0.2", features = ["no_cc"] } diff --git a/src/master.rs b/src/master.rs index 677072c..d4ead41 100644 --- a/src/master.rs +++ b/src/master.rs @@ -203,17 +203,17 @@ impl ShardHashes { let shard1 = self.find_shard(&shard.left_ancestor_mask()?)? .ok_or_else(|| error!("get_shard_cc_seqno: can't find shard1"))?; - if shard1.shard.is_ancestor_for(shard) { + if shard1.shard().is_ancestor_for(shard) { return Ok(shard1.descr.next_catchain_seqno) - } else if !shard.is_parent_for(&shard1.shard) { - fail!("get_shard_cc_seqno: invalid shard1 {} for {}", &shard1.shard, shard) + } else if !shard.is_parent_for(shard1.shard()) { + fail!("get_shard_cc_seqno: invalid shard1 {} for {}", shard1.shard(), shard) } let shard2 = self.find_shard(&shard.right_ancestor_mask()?)? .ok_or_else(|| error!("get_shard_cc_seqno: can't find shard2"))?; - if !shard.is_parent_for(&shard2.shard) { - fail!("get_shard_cc_seqno: invalid shard2 {} for {}", &shard2.shard, shard) + if !shard.is_parent_for(shard2.shard()) { + fail!("get_shard_cc_seqno: invalid shard2 {} for {}", shard2.shard(), shard) } Ok(std::cmp::max(shard1.descr.next_catchain_seqno, shard2.descr.next_catchain_seqno) + 1) @@ -306,15 +306,14 @@ impl ShardHashes { #[derive(Clone, Default, Debug, Eq, PartialEq)] pub struct McShardRecord { - pub shard: ShardIdent, pub descr: ShardDescr, pub block_id: BlockIdExt, } impl McShardRecord { pub fn from_shard_descr(shard: ShardIdent, descr: ShardDescr) -> Self { - let block_id = BlockIdExt::with_params(shard.clone(), descr.seq_no, descr.root_hash.clone(), descr.file_hash.clone()); - Self { shard, descr, block_id } + let block_id = BlockIdExt::with_params(shard, descr.seq_no, descr.root_hash.clone(), descr.file_hash.clone()); + Self { descr, block_id } } pub fn from_block(block: &Block, block_id: BlockIdExt) -> Result { @@ -322,7 +321,6 @@ impl McShardRecord { let value_flow = block.read_value_flow()?; Ok( McShardRecord { - shard: info.shard().clone(), descr: ShardDescr { seq_no: info.seq_no(), reg_mc_seqno: 0xffff_ffff, // by t-node @@ -349,7 +347,7 @@ impl McShardRecord { ) } - pub fn shard(&self) -> &ShardIdent { &self.shard } + pub fn shard(&self) -> &ShardIdent { self.block_id.shard() } pub fn descr(&self) -> &ShardDescr { &self.descr } diff --git a/src/shard.rs b/src/shard.rs index 4e1fbc0..83e19f6 100644 --- a/src/shard.rs +++ b/src/shard.rs @@ -235,7 +235,7 @@ shard_ident$00 shard_prefix: uint64 = ShardIdent; */ -#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)] +#[derive(Clone, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct ShardIdent { workchain_id: i32, prefix: u64, // with terminated bit! diff --git a/src/types.rs b/src/types.rs index fd3a980..9e96bc0 100644 --- a/src/types.rs +++ b/src/types.rs @@ -21,8 +21,9 @@ use std::time::{SystemTime, UNIX_EPOCH}; use num::{BigInt, BigUint, bigint::Sign, One, Zero}; use num_traits::cast::ToPrimitive; -use ton_types::{error, fail, Result, - BuilderData, Cell, CellType, IBitstring, HashmapE, HashmapType, SliceData, ExceptionCode, UInt256 +use ton_types::{ + error, fail, + Result, BuilderData, Cell, CellType, IBitstring, HashmapE, HashmapType, SliceData, UInt256 }; use crate::{ @@ -217,7 +218,7 @@ macro_rules! define_VarIntegerN { let bits = 8 - ($N as u8).leading_zeros(); let bytes = ((0 as $tt).leading_zeros() / 8 - self.0.leading_zeros() / 8) as usize; if bytes > $N { - fail!(ExceptionCode::IntegerOverflow) + fail!("cannot store {} grams, required {} bytes", self, bytes) } cell.append_bits(bytes, bits as usize)?; let be_bytes = self.0.to_be_bytes();