Skip to content

Commit

Permalink
0.6.35 (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomXY authored Nov 8, 2021
1 parent a8f4ed3 commit b83d09c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 42 deletions.
61 changes: 29 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@

[package]

edition = '2018'
build = './common/build/build.rs'
name = 'overlay'
version = '0.6.34'
description = 'Overlay protocol library'
edition = "2018"
build = "./common/build/build.rs"
name = "overlay"
version = "0.6.35"
description = "Overlay protocol library"
resolver = "2"

[workspace]

[dependencies]

arrayref = '0.3.5'
async-trait = '0.1.22'
base64 = '0.11.0'
failure = '0.1.6'
hex = '^0'
log = '0.4.8'
rand = '0.7.2'
sha2 = '0.8.0'
tokio = { version = '1.5.0', features = [ 'rt-multi-thread' ] }
ton_api = { git = 'https://github.com/tonlabs/ton-labs-tl.git', package = 'ton_api', tag = '0.2.110' }
adnl = { git = 'https://github.com/tonlabs/ton-labs-adnl.git', features = [ 'node' ], tag = '0.7.53' }
rldp = { git = 'https://github.com/tonlabs/ton-labs-rldp.git', tag = '0.7.49' }
ton_block = { git = 'https://github.com/tonlabs/ton-labs-block.git', tag = '1.7.27' }
ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.10.10' }
lockfree = { git = 'https://github.com/tonlabs/lockfree.git' }
async-trait = "0.1"
base64 = "0.13"
failure = "0.1"
hex = "0.4"
log = "0.4"
rand = "0.7"
sha2 = "0.9"
tokio = { version = "1.5", features = ["rt-multi-thread"] }

ton_api = { git = 'https://github.com/tonlabs/ton-labs-tl.git', package = 'ton_api', tag = '0.2.111' }
adnl = { git = 'https://github.com/tonlabs/ton-labs-adnl.git', features = [ 'node' ], tag = '0.7.55' }
rldp = { git = 'https://github.com/tonlabs/ton-labs-rldp.git', tag = '0.7.50' }
ton_block = { git = 'https://github.com/tonlabs/ton-labs-block.git', tag = '1.7.29' }
ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.10.11' }
lockfree = { git = "https://github.com/tonlabs/lockfree.git" }

[dev-dependencies]

dht = { git = 'https://github.com/tonlabs/ton-labs-dht.git' }
external-ip = '4.1.0'
log4rs = '0.8.3'
serde_json = '1.0.41'
socket2 = '0.3.19'
dht = { git = "https://github.com/tonlabs/ton-labs-dht.git", tag = '0.5.48' }
external-ip = "4.1"
log4rs = "1.0"
serde_json = "1.0"
socket2 = "0.3"

[features]

compression = [ 'adnl/compression' ]
telemetry = [ 'adnl/telemetry', 'rldp/telemetry' ]
compression = ["adnl/compression"]
telemetry = ["adnl/telemetry", "rldp/telemetry"]
telemetry_test_only = ["adnl/telemetry", "dht/telemetry", "rldp/telemetry"]
21 changes: 11 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ use adnl::{common::{tag_from_boxed_type, tag_from_unboxed_type}, telemetry::Metr
use adnl::node::DataCompression;
use rldp::{RaptorqDecoder, RaptorqEncoder, RldpNode};
use sha2::Digest;
use std::{sync::{Arc, atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering}}, time::Duration};
use std::{
convert::TryInto, sync::{Arc, atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering}},
time::Duration
};
#[cfg(feature = "telemetry")]
use std::time::Instant;
use ton_api::{
Expand Down Expand Up @@ -64,10 +67,11 @@ pub fn build_overlay_node_info(
if key.len() != 32 {
fail!("Bad public key length")
}
let key: [u8; 32] = key.as_slice().try_into()?;
let signature = base64::decode(signature)?;
let node = Node {
id: Ed25519 {
key: ton::int256(*arrayref::array_ref!(&key, 0, 32))
key: ton::int256(key)
}.into_boxed(),
overlay: ton::int256(*overlay.data()),
version,
Expand Down Expand Up @@ -287,23 +291,21 @@ impl OverlayShard {
const TIMEOUT_BROADCAST: u64 = 60; // Seconds

fn calc_broadcast_id(&self, data: &[u8]) -> Result<Option<BroadcastId>> {
let bcast_id = sha2::Sha256::digest(data);
let bcast_id = arrayref::array_ref!(bcast_id.as_slice(), 0, 32);
let bcast_id: [u8; 32] = sha2::Sha256::digest(data).try_into()?;
let added = add_unbound_object_to_map(
&self.owned_broadcasts,
*bcast_id,
bcast_id,
|| Ok(OwnedBroadcast::Other)
)?;
if !added {
Ok(None)
} else {
Ok(Some(*bcast_id))
Ok(Some(bcast_id))
}
}

fn calc_broadcast_to_sign(data: &[u8], date: i32, src: [u8; 32]) -> Result<Vec<u8>> {
let data_hash = sha2::Sha256::digest(data);
let data_hash = *arrayref::array_ref!(data_hash.as_slice(), 0, 32);
let data_hash: [u8; 32] = sha2::Sha256::digest(data).try_into()?;
let bcast_id = BroadcastOrdId {
src: ton::int256(src),
data_hash: ton::int256(data_hash),
Expand Down Expand Up @@ -337,8 +339,7 @@ impl OverlayShard {
flags
};
let broadcast_hash = hash(broadcast_id)?;
let part_data_hash = sha2::Sha256::digest(part);
let part_data_hash = *arrayref::array_ref!(part_data_hash.as_slice(), 0, 32);
let part_data_hash: [u8; 32] = sha2::Sha256::digest(part).try_into()?;

let part_id = BroadcastFecPartId {
broadcast_hash: ton::int256(broadcast_hash),
Expand Down

0 comments on commit b83d09c

Please sign in to comment.