Skip to content

Commit

Permalink
Merge pull request #52 from tonlabs/master-RC
Browse files Browse the repository at this point in the history
Automatic update project. #none
  • Loading branch information
tonjen authored Oct 20, 2021
2 parents e723300 + 4292bc7 commit ec283f3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
18 changes: 8 additions & 10 deletions src/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -306,23 +306,21 @@ 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<Self> {
let info = block.read_info()?;
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
Expand All @@ -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 }

Expand Down
2 changes: 1 addition & 1 deletion src/shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
7 changes: 4 additions & 3 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ec283f3

Please sign in to comment.