mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Fix fetching mc config for runSmcMethod, fix caching in LS (#915)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
c7302bc4a3
commit
310dd6dec1
5 changed files with 51 additions and 4 deletions
|
@ -157,7 +157,7 @@ void LiteQuery::start_up() {
|
|||
});
|
||||
return;
|
||||
}
|
||||
use_cache_ = !cache_.empty() && query_obj_->get_id() == lite_api::liteServer_runSmcMethod::ID;
|
||||
use_cache_ = use_cache();
|
||||
if (use_cache_) {
|
||||
cache_key_ = td::sha256_bits256(query_);
|
||||
td::actor::send_closure(
|
||||
|
@ -173,6 +173,22 @@ void LiteQuery::start_up() {
|
|||
}
|
||||
}
|
||||
|
||||
bool LiteQuery::use_cache() {
|
||||
if (cache_.empty()) {
|
||||
return false;
|
||||
}
|
||||
bool use = false;
|
||||
lite_api::downcast_call(
|
||||
*query_obj_,
|
||||
td::overloaded(
|
||||
[&](lite_api::liteServer_runSmcMethod& q) {
|
||||
// wc=-1, seqno=-1 means "use latest mc block"
|
||||
use = q.id_->workchain_ != masterchainId || q.id_->seqno_ != -1;
|
||||
},
|
||||
[&](auto& obj) { use = false; }));
|
||||
return use;
|
||||
}
|
||||
|
||||
void LiteQuery::perform() {
|
||||
td::actor::send_closure(manager_, &ValidatorManager::add_lite_query_stats, query_obj_->get_id());
|
||||
lite_api::downcast_call(
|
||||
|
@ -1245,8 +1261,24 @@ void LiteQuery::finish_getAccountState(td::BufferSlice shard_proof) {
|
|||
return;
|
||||
}
|
||||
if (mode_ & 0x10000) {
|
||||
finish_runSmcMethod(std::move(shard_proof), proof.move_as_ok(), std::move(acc_root), sstate.gen_utime,
|
||||
sstate.gen_lt);
|
||||
if (!mc_state_.is_null()) {
|
||||
finish_runSmcMethod(std::move(shard_proof), proof.move_as_ok(), std::move(acc_root), sstate.gen_utime,
|
||||
sstate.gen_lt);
|
||||
return;
|
||||
}
|
||||
shard_proof_ = std::move(shard_proof);
|
||||
proof_ = proof.move_as_ok();
|
||||
set_continuation(
|
||||
[&, base_blk_id = base_blk_id_, acc_root, utime = sstate.gen_utime, lt = sstate.gen_lt]() mutable -> void {
|
||||
base_blk_id_ = base_blk_id; // It gets overridden by request_mc_block_data_state
|
||||
finish_runSmcMethod(std::move(shard_proof_), std::move(proof_), std::move(acc_root), utime, lt);
|
||||
});
|
||||
td::optional<BlockIdExt> master_ref = state_->get_master_ref();
|
||||
if (!master_ref) {
|
||||
fatal_error("masterchain ref block is not available");
|
||||
return;
|
||||
}
|
||||
request_mc_block_data_state(master_ref.value());
|
||||
return;
|
||||
}
|
||||
td::BufferSlice data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue