Skip to content

Commit 8289d25

Browse files
Merge branch 'async' of github.com:tonstack/lite-client into async
2 parents 8a93445 + 86a7cfa commit 8289d25

File tree

4 files changed

+48
-35
lines changed

4 files changed

+48
-35
lines changed

Diff for: liteapi/src/server.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::time::Duration;
66

77
use adnl::AdnlPeer;
88
use adnl::AdnlPrivateKey;
9-
use log::error;
109
use tokio::net::TcpListener;
1110
use tokio::net::ToSocketAddrs;
1211
use tokio_tower::multiplex::Server;
@@ -40,19 +39,21 @@ pub async fn serve<A, S, M>(addr: &A, private_key: S, mut service_maker: M) -> R
4039
// > will be logged at the `error` level, since it is still a big deal,
4140
// > and then the listener will sleep for 1 second.
4241
if !matches!(e.kind(), ErrorKind::ConnectionRefused | ErrorKind::ConnectionAborted | ErrorKind::ConnectionReset) {
43-
error!("accept error: {e}");
42+
log::error!("accept error: {e}");
4443
tokio::time::sleep(Duration::from_secs(1)).await;
4544
}
4645
continue;
4746
}
4847
};
48+
log::debug!("[{addr:?}] Accepted socket");
4949
poll_fn(|cx| service_maker.poll_ready(cx)).await.expect("polling service maker failed");
5050
let service = service_maker.make_service(addr).await.expect("making service failed");
5151
let private_key = private_key.clone();
5252
tokio::spawn(async move {
5353
let adnl = AdnlPeer::handle_handshake(socket, |_| Some(private_key.clone())).await.expect("handshake failed");
54+
log::debug!("[{addr:?}] Handshake performed");
5455
let lite = LitePeer::new(adnl);
5556
Server::new(lite, service).await.expect("server failed");
5657
});
5758
}
58-
}
59+
}

Diff for: liteapi/src/tl/common.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl String {
4040

4141
/// int256 8*[ int ] = Int256;
4242
#[derive(TlRead, TlWrite, Derivative)]
43-
#[derivative(Debug, Clone, PartialEq, Eq, Default)]
43+
#[derivative(Debug, Clone, PartialEq, Eq, Default, Hash)]
4444
pub struct Int256(#[derivative(Debug(format_with = "fmt_bytes"))] pub [u8; 32]);
4545

4646
impl FromStr for Int256 {
@@ -81,7 +81,7 @@ pub struct BlockId {
8181

8282
/// tonNode.blockIdExt workchain:int shard:long seqno:int root_hash:int256 file_hash:int256 = tonNode.BlockIdExt;
8383
#[derive(TlRead, TlWrite, Derivative)]
84-
#[derivative(Debug, Clone, PartialEq)]
84+
#[derivative(Debug, Clone, PartialEq, Eq, Hash)]
8585
pub struct BlockIdExt {
8686
pub workchain: i32,
8787
pub shard: u64,
@@ -110,7 +110,7 @@ pub struct AccountId {
110110
// #[tl(boxed, id = "liteServer.transactionId3", scheme_inline = r##"liteServer.transactionId3 account:int256 lt:long = liteServer.TransactionId3;"##)]
111111
pub struct TransactionId3 {
112112
pub account: Int256,
113-
pub lt: i64,
113+
pub lt: u64,
114114
}
115115

116116
/// liteServer.signature node_id_short:int256 signature:bytes = liteServer.Signature;
@@ -131,8 +131,8 @@ pub struct Signature {
131131
scheme_inline = r##"liteServer.signatureSet validator_set_hash:int catchain_seqno:int signatures:(vector liteServer.signature) = liteServer.SignatureSet;"##
132132
)]
133133
pub struct SignatureSet {
134-
pub validator_set_hash: i32,
135-
pub catchain_seqno: i32,
134+
pub validator_set_hash: u32,
135+
pub catchain_seqno: u32,
136136
pub signatures: Vec<Signature>,
137137
}
138138

@@ -186,7 +186,7 @@ pub struct TransactionId {
186186
#[tl(flags_bit = "mode.0")]
187187
pub account: Option<Int256>,
188188
#[tl(flags_bit = "mode.1")]
189-
pub lt: Option<i64>,
189+
pub lt: Option<u64>,
190190
#[tl(flags_bit = "mode.2")]
191191
pub hash: Option<Int256>,
192-
}
192+
}

Diff for: liteapi/src/tl/request.rs

+24-12
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ pub struct WrappedRequest {
3434
scheme_inline = r##"liteServer.waitMasterchainSeqno seqno:int timeout_ms:int = Object;"##
3535
)]
3636
pub struct WaitMasterchainSeqno {
37-
pub seqno: i32,
38-
pub timeout_ms: i32,
37+
pub seqno: u32,
38+
pub timeout_ms: u32,
3939
}
4040

4141
#[derive(TlRead, TlWrite, Derivative)]
@@ -93,7 +93,7 @@ pub struct RunSmcMethod {
9393
pub mode: u32,
9494
pub id: BlockIdExt,
9595
pub account: AccountId,
96-
pub method_id: i64,
96+
pub method_id: u64,
9797
pub params: Vec<u8>,
9898
}
9999

@@ -117,15 +117,15 @@ pub struct GetAllShardsInfo {
117117
pub struct GetOneTransaction {
118118
pub id: BlockIdExt,
119119
pub account: AccountId,
120-
pub lt: i64,
120+
pub lt: u64,
121121
}
122122

123123
#[derive(TlRead, TlWrite, Derivative)]
124124
#[derivative(Debug, Clone, PartialEq)]
125125
pub struct GetTransactions {
126-
pub count: i32,
126+
pub count: u32,
127127
pub account: AccountId,
128-
pub lt: i64,
128+
pub lt: u64,
129129
pub hash: Int256,
130130
}
131131

@@ -135,10 +135,22 @@ pub struct LookupBlock {
135135
#[tl(flags)]
136136
pub mode: (),
137137
pub id: BlockId,
138+
#[tl(flags_bit = "mode.0")]
139+
pub seqno: Option<()>,
138140
#[tl(flags_bit = "mode.1")]
139-
pub lt: Option<i64>,
141+
pub lt: Option<u64>,
140142
#[tl(flags_bit = "mode.2")]
141-
pub utime: Option<i32>,
143+
pub utime: Option<u32>,
144+
#[tl(flags_bit = "mode.4")]
145+
pub with_state_update: Option<()>,
146+
#[tl(flags_bit = "mode.5")]
147+
pub with_value_flow: Option<()>,
148+
#[tl(flags_bit = "mode.8")]
149+
pub with_extra: Option<()>,
150+
#[tl(flags_bit = "mode.9")]
151+
pub with_shard_hashes: Option<()>,
152+
#[tl(flags_bit = "mode.10")]
153+
pub with_prev_blk_signatures: Option<()>,
142154
}
143155

144156
#[derive(TlRead, TlWrite, Derivative)]
@@ -147,7 +159,7 @@ pub struct ListBlockTransactions {
147159
pub id: BlockIdExt,
148160
#[tl(flags)]
149161
pub mode: (),
150-
pub count: i32,
162+
pub count: u32,
151163
#[tl(flags_bit = "mode.7")]
152164
pub after: Option<TransactionId3>,
153165
#[tl(flags_bit = "mode.6")]
@@ -217,11 +229,11 @@ pub struct GetValidatorStats {
217229
#[tl(flags)]
218230
pub mode: (),
219231
id: BlockIdExt,
220-
pub limit: i32,
232+
pub limit: u32,
221233
#[tl(flags_bit = "mode.0")]
222234
pub start_after: Option<Int256>,
223235
#[tl(flags_bit = "mode.2")]
224-
pub modified_after: Option<i32>,
236+
pub modified_after: Option<u32>,
225237
}
226238

227239
#[derive(TlRead, TlWrite, Derivative)]
@@ -307,4 +319,4 @@ pub enum Request {
307319
/// liteServer.getValidatorStats#091a58bc mode:# id:tonNode.blockIdExt limit:int start_after:mode.0?int256 modified_after:mode.2?int = liteServer.ValidatorStats;
308320
#[tl(id = 0xe7253699)]
309321
GetValidatorStats(GetValidatorStats),
310-
}
322+
}

Diff for: liteapi/src/tl/response.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@ pub struct MasterchainInfo {
1717
pub struct MasterchainInfoExt {
1818
#[tl(flags)]
1919
pub mode: (),
20-
pub version: i32,
21-
pub capabilities: i64,
20+
pub version: u32,
21+
pub capabilities: u64,
2222
pub last: BlockIdExt,
23-
pub last_utime: i32,
24-
pub now: i32,
23+
pub last_utime: u32,
24+
pub now: u32,
2525
pub state_root_hash: Int256,
2626
pub init: ZeroStateIdExt,
2727
}
2828

2929
#[derive(TlRead, TlWrite, Derivative)]
3030
#[derivative(Debug, Clone, PartialEq)]
3131
pub struct CurrentTime {
32-
pub now: i32,
32+
pub now: u32,
3333
}
3434

3535
#[derive(TlRead, TlWrite, Derivative)]
3636
#[derivative(Debug, Clone, PartialEq)]
3737
pub struct Version {
38-
pub mode: i32,
39-
pub version: i32,
40-
pub capabilities: i64,
41-
pub now: i32,
38+
pub mode: u32,
39+
pub version: u32,
40+
pub capabilities: u64,
41+
pub now: u32,
4242
}
4343

4444
#[derive(TlRead, TlWrite, Derivative)]
@@ -79,7 +79,7 @@ pub struct BlockHeader {
7979
#[derive(TlRead, TlWrite, Derivative)]
8080
#[derivative(Debug, Clone, PartialEq)]
8181
pub struct SendMsgStatus {
82-
pub status: i32,
82+
pub status: u32,
8383
}
8484

8585
#[derive(TlRead, TlWrite, Derivative)]
@@ -157,7 +157,7 @@ pub struct TransactionId {
157157
#[tl(flags_bit = "mode.0")]
158158
pub account: Option<Int256>,
159159
#[tl(flags_bit = "mode.1")]
160-
pub lt: Option<i64>,
160+
pub lt: Option<u64>,
161161
#[tl(flags_bit = "mode.2")]
162162
pub hash: Option<Int256>,
163163
}
@@ -166,7 +166,7 @@ pub struct TransactionId {
166166
#[derivative(Debug, Clone, PartialEq)]
167167
pub struct BlockTransactions {
168168
pub id: BlockIdExt,
169-
pub req_count: i32,
169+
pub req_count: u32,
170170
pub incomplete: bool,
171171
pub ids: Vec<TransactionId>,
172172
pub proof: Vec<u8>,
@@ -211,7 +211,7 @@ pub struct ValidatorStats {
211211
#[tl(flags)]
212212
pub mode: (),
213213
pub id: BlockIdExt,
214-
pub count: i32,
214+
pub count: u32,
215215
pub complete: bool,
216216
pub state_proof: Vec<u8>,
217217
pub data_proof: Vec<u8>,

0 commit comments

Comments
 (0)