diff --git a/liteapi/src/server.rs b/liteapi/src/server.rs index eaa1aa9..47b41ec 100644 --- a/liteapi/src/server.rs +++ b/liteapi/src/server.rs @@ -6,7 +6,6 @@ use std::time::Duration; use adnl::AdnlPeer; use adnl::AdnlPrivateKey; -use log::error; use tokio::net::TcpListener; use tokio::net::ToSocketAddrs; use tokio_tower::multiplex::Server; @@ -40,19 +39,21 @@ pub async fn serve(addr: &A, private_key: S, mut service_maker: M) -> R // > will be logged at the `error` level, since it is still a big deal, // > and then the listener will sleep for 1 second. if !matches!(e.kind(), ErrorKind::ConnectionRefused | ErrorKind::ConnectionAborted | ErrorKind::ConnectionReset) { - error!("accept error: {e}"); + log::error!("accept error: {e}"); tokio::time::sleep(Duration::from_secs(1)).await; } continue; } }; + log::debug!("[{addr:?}] Accepted socket"); poll_fn(|cx| service_maker.poll_ready(cx)).await.expect("polling service maker failed"); let service = service_maker.make_service(addr).await.expect("making service failed"); let private_key = private_key.clone(); tokio::spawn(async move { let adnl = AdnlPeer::handle_handshake(socket, |_| Some(private_key.clone())).await.expect("handshake failed"); + log::debug!("[{addr:?}] Handshake performed"); let lite = LitePeer::new(adnl); Server::new(lite, service).await.expect("server failed"); }); } -} \ No newline at end of file +} diff --git a/liteapi/src/tl/common.rs b/liteapi/src/tl/common.rs index a8a6a9a..0f3d8e2 100644 --- a/liteapi/src/tl/common.rs +++ b/liteapi/src/tl/common.rs @@ -40,7 +40,7 @@ impl String { /// int256 8*[ int ] = Int256; #[derive(TlRead, TlWrite, Derivative)] -#[derivative(Debug, Clone, PartialEq, Eq, Default)] +#[derivative(Debug, Clone, PartialEq, Eq, Default, Hash)] pub struct Int256(#[derivative(Debug(format_with = "fmt_bytes"))] pub [u8; 32]); impl FromStr for Int256 { @@ -81,7 +81,7 @@ pub struct BlockId { /// tonNode.blockIdExt workchain:int shard:long seqno:int root_hash:int256 file_hash:int256 = tonNode.BlockIdExt; #[derive(TlRead, TlWrite, Derivative)] -#[derivative(Debug, Clone, PartialEq)] +#[derivative(Debug, Clone, PartialEq, Eq, Hash)] pub struct BlockIdExt { pub workchain: i32, pub shard: u64, @@ -110,7 +110,7 @@ pub struct AccountId { // #[tl(boxed, id = "liteServer.transactionId3", scheme_inline = r##"liteServer.transactionId3 account:int256 lt:long = liteServer.TransactionId3;"##)] pub struct TransactionId3 { pub account: Int256, - pub lt: i64, + pub lt: u64, } /// liteServer.signature node_id_short:int256 signature:bytes = liteServer.Signature; @@ -131,8 +131,8 @@ pub struct Signature { scheme_inline = r##"liteServer.signatureSet validator_set_hash:int catchain_seqno:int signatures:(vector liteServer.signature) = liteServer.SignatureSet;"## )] pub struct SignatureSet { - pub validator_set_hash: i32, - pub catchain_seqno: i32, + pub validator_set_hash: u32, + pub catchain_seqno: u32, pub signatures: Vec, } @@ -186,7 +186,7 @@ pub struct TransactionId { #[tl(flags_bit = "mode.0")] pub account: Option, #[tl(flags_bit = "mode.1")] - pub lt: Option, + pub lt: Option, #[tl(flags_bit = "mode.2")] pub hash: Option, -} \ No newline at end of file +} diff --git a/liteapi/src/tl/request.rs b/liteapi/src/tl/request.rs index 19d33cc..0c17b3c 100644 --- a/liteapi/src/tl/request.rs +++ b/liteapi/src/tl/request.rs @@ -34,8 +34,8 @@ pub struct WrappedRequest { scheme_inline = r##"liteServer.waitMasterchainSeqno seqno:int timeout_ms:int = Object;"## )] pub struct WaitMasterchainSeqno { - pub seqno: i32, - pub timeout_ms: i32, + pub seqno: u32, + pub timeout_ms: u32, } #[derive(TlRead, TlWrite, Derivative)] @@ -93,7 +93,7 @@ pub struct RunSmcMethod { pub mode: u32, pub id: BlockIdExt, pub account: AccountId, - pub method_id: i64, + pub method_id: u64, pub params: Vec, } @@ -117,15 +117,15 @@ pub struct GetAllShardsInfo { pub struct GetOneTransaction { pub id: BlockIdExt, pub account: AccountId, - pub lt: i64, + pub lt: u64, } #[derive(TlRead, TlWrite, Derivative)] #[derivative(Debug, Clone, PartialEq)] pub struct GetTransactions { - pub count: i32, + pub count: u32, pub account: AccountId, - pub lt: i64, + pub lt: u64, pub hash: Int256, } @@ -135,10 +135,22 @@ pub struct LookupBlock { #[tl(flags)] pub mode: (), pub id: BlockId, + #[tl(flags_bit = "mode.0")] + pub seqno: Option<()>, #[tl(flags_bit = "mode.1")] - pub lt: Option, + pub lt: Option, #[tl(flags_bit = "mode.2")] - pub utime: Option, + pub utime: Option, + #[tl(flags_bit = "mode.4")] + pub with_state_update: Option<()>, + #[tl(flags_bit = "mode.5")] + pub with_value_flow: Option<()>, + #[tl(flags_bit = "mode.8")] + pub with_extra: Option<()>, + #[tl(flags_bit = "mode.9")] + pub with_shard_hashes: Option<()>, + #[tl(flags_bit = "mode.10")] + pub with_prev_blk_signatures: Option<()>, } #[derive(TlRead, TlWrite, Derivative)] @@ -147,7 +159,7 @@ pub struct ListBlockTransactions { pub id: BlockIdExt, #[tl(flags)] pub mode: (), - pub count: i32, + pub count: u32, #[tl(flags_bit = "mode.7")] pub after: Option, #[tl(flags_bit = "mode.6")] @@ -217,11 +229,11 @@ pub struct GetValidatorStats { #[tl(flags)] pub mode: (), id: BlockIdExt, - pub limit: i32, + pub limit: u32, #[tl(flags_bit = "mode.0")] pub start_after: Option, #[tl(flags_bit = "mode.2")] - pub modified_after: Option, + pub modified_after: Option, } #[derive(TlRead, TlWrite, Derivative)] @@ -307,4 +319,4 @@ pub enum Request { /// liteServer.getValidatorStats#091a58bc mode:# id:tonNode.blockIdExt limit:int start_after:mode.0?int256 modified_after:mode.2?int = liteServer.ValidatorStats; #[tl(id = 0xe7253699)] GetValidatorStats(GetValidatorStats), -} \ No newline at end of file +} diff --git a/liteapi/src/tl/response.rs b/liteapi/src/tl/response.rs index 95b0834..ec9adcf 100644 --- a/liteapi/src/tl/response.rs +++ b/liteapi/src/tl/response.rs @@ -17,11 +17,11 @@ pub struct MasterchainInfo { pub struct MasterchainInfoExt { #[tl(flags)] pub mode: (), - pub version: i32, - pub capabilities: i64, + pub version: u32, + pub capabilities: u64, pub last: BlockIdExt, - pub last_utime: i32, - pub now: i32, + pub last_utime: u32, + pub now: u32, pub state_root_hash: Int256, pub init: ZeroStateIdExt, } @@ -29,16 +29,16 @@ pub struct MasterchainInfoExt { #[derive(TlRead, TlWrite, Derivative)] #[derivative(Debug, Clone, PartialEq)] pub struct CurrentTime { - pub now: i32, + pub now: u32, } #[derive(TlRead, TlWrite, Derivative)] #[derivative(Debug, Clone, PartialEq)] pub struct Version { - pub mode: i32, - pub version: i32, - pub capabilities: i64, - pub now: i32, + pub mode: u32, + pub version: u32, + pub capabilities: u64, + pub now: u32, } #[derive(TlRead, TlWrite, Derivative)] @@ -79,7 +79,7 @@ pub struct BlockHeader { #[derive(TlRead, TlWrite, Derivative)] #[derivative(Debug, Clone, PartialEq)] pub struct SendMsgStatus { - pub status: i32, + pub status: u32, } #[derive(TlRead, TlWrite, Derivative)] @@ -157,7 +157,7 @@ pub struct TransactionId { #[tl(flags_bit = "mode.0")] pub account: Option, #[tl(flags_bit = "mode.1")] - pub lt: Option, + pub lt: Option, #[tl(flags_bit = "mode.2")] pub hash: Option, } @@ -166,7 +166,7 @@ pub struct TransactionId { #[derivative(Debug, Clone, PartialEq)] pub struct BlockTransactions { pub id: BlockIdExt, - pub req_count: i32, + pub req_count: u32, pub incomplete: bool, pub ids: Vec, pub proof: Vec, @@ -211,7 +211,7 @@ pub struct ValidatorStats { #[tl(flags)] pub mode: (), pub id: BlockIdExt, - pub count: i32, + pub count: u32, pub complete: bool, pub state_proof: Vec, pub data_proof: Vec,