forked from toncenter/ton-http-api-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpromise_function_req.cpp
More file actions
50 lines (43 loc) · 1.46 KB
/
Copy pathpromise_function_req.cpp
File metadata and controls
50 lines (43 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <unistd.h>
#include "auto/tl/tonlib_api.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "tonlib-multiclient/multi_client.h"
#include "tonlib-multiclient/request.h"
#include "tonlib/Logging.h"
int main(int argc, char* argv[]) {
tonlib::Logging::set_verbosity_level(3);
multiclient::MultiClient client(
multiclient::MultiClientConfig{
.global_config_path = std::filesystem::path("/tmp/global-config.json"),
.key_store_root = std::filesystem::path("/tmp/keystore"),
.scheduler_threads = 6,
}
);
sleep(5);
while (true) {
sleep(5);
LOG(INFO) << "send request";
auto resp = client.send_request_function(
multiclient::RequestFunction<ton::tonlib_api::raw_getAccountState>{
.parameters = {.mode = multiclient::RequestMode::Broadcast},
.request_creator =
[]() {
return ton::tonlib_api::make_object<ton::tonlib_api::raw_getAccountState>(
ton::tonlib_api::make_object<ton::tonlib_api::accountAddress>(
"UQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqEBI"
)
);
},
}
);
if (resp.is_error()) {
LOG(ERROR) << "resp: " << resp.error();
continue;
}
auto res = resp.move_as_ok();
LOG(INFO) << "balance: " << res->balance_ << " block: " << res->block_id_->seqno_
<< " code: " << td::hex_encode(res->code_) << " data: " << td::hex_encode(res->data_);
}
return 0;
}