1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Simplify selecting shards for monitor

This commit is contained in:
SpyCheese 2022-10-03 17:55:37 +03:00
parent c2dde00459
commit 81c0e920c5
11 changed files with 66 additions and 75 deletions

View file

@ -91,7 +91,7 @@ void ShardClient::start_up_init_mode() {
auto vec = masterchain_state_->get_shards();
for (auto &shard : vec) {
if (shards_to_monitor_.count(shard->shard())) {
if (opts_->need_monitor(shard->shard(), masterchain_state_)) {
auto P = td::PromiseCreator::lambda([promise = ig.get_promise()](td::Result<td::Ref<ShardState>> R) mutable {
R.ensure();
promise.set_value(td::Unit());
@ -192,7 +192,7 @@ void ShardClient::apply_all_shards() {
auto vec = masterchain_state_->get_shards();
for (auto &shard : vec) {
if (shards_to_monitor_.count(shard->shard())) {
if (opts_->need_monitor(shard->shard(), masterchain_state_)) {
auto Q = td::PromiseCreator::lambda([SelfId = actor_id(this), promise = ig.get_promise(),
shard = shard->shard()](td::Result<td::Ref<ShardState>> R) mutable {
if (R.is_error()) {
@ -254,23 +254,9 @@ void ShardClient::build_shard_overlays() {
for (const auto &info : masterchain_state_->get_shards()) {
auto shard = info->shard();
workchains.insert(shard.workchain);
bool will_split = shard.pfx_len() < max_shard_pfx_len &&
(info->fsm_state() == McShardHash::FsmState::fsm_split || info->before_split());
bool will_merge =
shard.pfx_len() > 0 && (info->fsm_state() == McShardHash::FsmState::fsm_merge || info->before_merge());
if (opts_->need_monitor(shard) || (will_merge && opts_->need_monitor(shard_parent(shard)))) {
if (opts_->need_monitor(shard, masterchain_state_)) {
new_shards_to_monitor.insert(shard);
}
if (will_merge && opts_->need_monitor(shard_parent(shard))) {
new_shards_to_monitor.insert(shard_parent(shard));
}
if (will_split) {
for (int id = 0; id < 2; ++id) {
if (opts_->need_monitor(shard_child(shard, id))) {
new_shards_to_monitor.insert(shard_child(shard, id));
}
}
}
}
std::vector<BlockIdExt> new_workchains;
@ -278,7 +264,8 @@ void ShardClient::build_shard_overlays() {
ton::WorkchainId wc = wpair.first;
const block::WorkchainInfo *winfo = wpair.second.get();
auto shard = ShardIdFull(wc);
if (workchains.count(wc) == 0 && winfo->active && winfo->enabled_since <= cur_time && opts_->need_monitor(shard)) {
if (workchains.count(wc) == 0 && winfo->active && winfo->enabled_since <= cur_time &&
opts_->need_monitor(shard, masterchain_state_)) {
new_shards_to_monitor.insert(shard);
if (shards_to_monitor_.count(shard) == 0) {
new_workchains.push_back(BlockIdExt(wc, shardIdAll, 0, winfo->zerostate_root_hash, winfo->zerostate_file_hash));