|
42 | 42 | #include "signature-set.hpp"
|
43 | 43 | #include "fabric.h"
|
44 | 44 | #include <ctime>
|
| 45 | +#include "td/actor/MultiPromise.h" |
| 46 | +#include "collator-impl.h" |
45 | 47 |
|
46 | 48 | namespace ton {
|
47 | 49 |
|
@@ -282,6 +284,9 @@ void LiteQuery::perform() {
|
282 | 284 | [&](lite_api::liteServer_nonfinal_getValidatorGroups& q) {
|
283 | 285 | this->perform_nonfinal_getValidatorGroups(q.mode_, ShardIdFull{q.wc_, (ShardId)q.shard_});
|
284 | 286 | },
|
| 287 | + [&](lite_api::liteServer_getOutMsgQueueSizes& q) { |
| 288 | + this->perform_getOutMsgQueueSizes(q.mode_ & 1 ? ShardIdFull(q.wc_, q.shard_) : td::optional<ShardIdFull>()); |
| 289 | + }, |
285 | 290 | [&](auto& obj) { this->abort_query(td::Status::Error(ErrorCode::protoviolation, "unknown query")); }));
|
286 | 291 | }
|
287 | 292 |
|
@@ -3216,6 +3221,53 @@ void LiteQuery::continue_getShardBlockProof(Ref<BlockData> cur_block,
|
3216 | 3221 | });
|
3217 | 3222 | }
|
3218 | 3223 |
|
| 3224 | +void LiteQuery::perform_getOutMsgQueueSizes(td::optional<ShardIdFull> shard) { |
| 3225 | + LOG(INFO) << "started a getOutMsgQueueSizes" << (shard ? shard.value().to_str() : "") << " liteserver query"; |
| 3226 | + td::actor::send_closure_later( |
| 3227 | + manager_, &ton::validator::ValidatorManager::get_last_liteserver_state_block, |
| 3228 | + [Self = actor_id(this), shard](td::Result<std::pair<Ref<MasterchainState>, BlockIdExt>> res) { |
| 3229 | + if (res.is_error()) { |
| 3230 | + td::actor::send_closure(Self, &LiteQuery::abort_query, res.move_as_error()); |
| 3231 | + } else { |
| 3232 | + td::actor::send_closure_later(Self, &LiteQuery::continue_getOutMsgQueueSizes, shard, res.ok().first); |
| 3233 | + } |
| 3234 | + }); |
| 3235 | +} |
| 3236 | + |
| 3237 | +void LiteQuery::continue_getOutMsgQueueSizes(td::optional<ShardIdFull> shard, Ref<MasterchainState> state) { |
| 3238 | + std::vector<BlockIdExt> blocks; |
| 3239 | + if (!shard || shard_intersects(shard.value(), state->get_shard())) { |
| 3240 | + blocks.push_back(state->get_block_id()); |
| 3241 | + } |
| 3242 | + for (auto& x : state->get_shards()) { |
| 3243 | + if (!shard || shard_intersects(shard.value(), x->shard())) { |
| 3244 | + blocks.push_back(x->top_block_id()); |
| 3245 | + } |
| 3246 | + } |
| 3247 | + auto res = std::make_shared<std::vector<tl_object_ptr<lite_api::liteServer_outMsgQueueSize>>>(blocks.size()); |
| 3248 | + td::MultiPromise mp; |
| 3249 | + auto ig = mp.init_guard(); |
| 3250 | + for (size_t i = 0; i < blocks.size(); ++i) { |
| 3251 | + td::actor::send_closure(manager_, &ValidatorManager::get_out_msg_queue_size, blocks[i], |
| 3252 | + [promise = ig.get_promise(), res, i, id = blocks[i]](td::Result<td::uint32> R) mutable { |
| 3253 | + TRY_RESULT_PROMISE(promise, value, std::move(R)); |
| 3254 | + res->at(i) = create_tl_object<lite_api::liteServer_outMsgQueueSize>( |
| 3255 | + create_tl_lite_block_id(id), value); |
| 3256 | + promise.set_value(td::Unit()); |
| 3257 | + }); |
| 3258 | + } |
| 3259 | + ig.add_promise([Self = actor_id(this), res](td::Result<td::Unit> R) { |
| 3260 | + if (R.is_error()) { |
| 3261 | + td::actor::send_closure(Self, &LiteQuery::abort_query, R.move_as_error()); |
| 3262 | + return; |
| 3263 | + } |
| 3264 | + td::actor::send_closure(Self, &LiteQuery::finish_query, |
| 3265 | + create_serialize_tl_object<lite_api::liteServer_outMsgQueueSizes>( |
| 3266 | + std::move(*res), Collator::get_skip_externals_queue_size()), |
| 3267 | + false); |
| 3268 | + }); |
| 3269 | +} |
| 3270 | + |
3219 | 3271 | void LiteQuery::perform_nonfinal_getCandidate(td::Bits256 source, BlockIdExt blkid, td::Bits256 collated_data_hash) {
|
3220 | 3272 | LOG(INFO) << "started a nonfinal.getCandidate liteserver query";
|
3221 | 3273 | td::actor::send_closure_later(
|
|
0 commit comments