From 86250706b8ce8529c8e9f3e24baf6b69aff523b7 Mon Sep 17 00:00:00 2001 From: SpyCheese Date: Tue, 13 Sep 2022 16:02:55 +0300 Subject: [PATCH] Change format of specifying shards to monitor --- lite-client/lite-client.cpp | 5 ++++- validator-engine/validator-engine.cpp | 2 +- validator/collator-node.cpp | 2 +- validator/validator-group.cpp | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lite-client/lite-client.cpp b/lite-client/lite-client.cpp index 7165ca53..2b559bc7 100644 --- a/lite-client/lite-client.cpp +++ b/lite-client/lite-client.cpp @@ -81,6 +81,9 @@ int TestNode::LiteServer::max_common_prefix(ton::ShardIdFull shard) const { } int res = -1; for (const ton::ShardIdFull &our_shard : shards) { + if (ton::shard_is_ancestor(our_shard, shard)) { + return shard.pfx_len(); + } if (shard.workchain == our_shard.workchain) { int x = std::min({shard.pfx_len(), our_shard.pfx_len(), ton::count_matching_bits(shard.shard, our_shard.shard)}); res = std::max(res, x); @@ -92,7 +95,7 @@ int TestNode::LiteServer::max_common_prefix(ton::ShardIdFull shard) const { bool TestNode::LiteServer::supports_shard(ton::ShardIdFull shard) const { return is_full || shard.is_masterchain() || std::any_of(shards.begin(), shards.end(), - [&](const ton::ShardIdFull& our_shard) { return ton::shard_is_ancestor(shard, our_shard); }); + [&](const ton::ShardIdFull& our_shard) { return ton::shard_intersects(shard, our_shard); }); } void TestNode::run() { diff --git a/validator-engine/validator-engine.cpp b/validator-engine/validator-engine.cpp index 2aaff674..bb3bd059 100644 --- a/validator-engine/validator-engine.cpp +++ b/validator-engine/validator-engine.cpp @@ -1413,7 +1413,7 @@ void ValidatorEngine::set_shard_check_function() { validator_options_.write().set_shard_check_function( [shards = std::move(shards)](ton::ShardIdFull shard) -> bool { for (auto s : shards) { - if (shard_is_ancestor(shard, s)) { + if (shard_intersects(shard, s)) { return true; } } diff --git a/validator/collator-node.cpp b/validator/collator-node.cpp index c11b01c8..0a2a050e 100644 --- a/validator/collator-node.cpp +++ b/validator/collator-node.cpp @@ -170,7 +170,7 @@ void CollatorNode::receive_query_cont(adnl::AdnlNodeIdShort src, ShardIdFull sha bool CollatorNode::collate_shard(ShardIdFull shard) const { for (ShardIdFull our_shard : shards_) { - if (shard_is_ancestor(shard, our_shard)) { + if (shard_intersects(shard, our_shard)) { return true; } } diff --git a/validator/validator-group.cpp b/validator/validator-group.cpp index 88a473ff..21517a20 100644 --- a/validator/validator-group.cpp +++ b/validator/validator-group.cpp @@ -364,7 +364,7 @@ void ValidatorGroup::send_collate_query(td::uint32 round_id, td::Timestamp timeo // TODO: some way to choose node (similar to "unreliability" in full-node) int cnt = 0; for (const block::CollatorNodeDescr& c : collator_config_.collator_nodes) { - if (shard_is_ancestor(shard_, c.shard) && td::Random::fast(0, cnt) == 0) { + if (shard_intersects(shard_, c.shard) && td::Random::fast(0, cnt) == 0) { collator = adnl::AdnlNodeIdShort(c.adnl_id); ++cnt; }