|
27 | 27 | #include "td/utils/overloaded.h" |
28 | 28 | #include "tl-utils/tl-utils.hpp" |
29 | 29 | #include "auto/tl/ton_api.hpp" |
| 30 | +#include "common/delay.h" |
30 | 31 | #include "td/actor/MultiPromise.h" |
31 | 32 |
|
32 | 33 | namespace ton { |
@@ -545,8 +546,9 @@ void NodeActor::loop_queries() { |
545 | 546 | auto it = peers_.find(part.peer_id); |
546 | 547 | CHECK(it != peers_.end()); |
547 | 548 | auto &state = it->second.state; |
548 | | - CHECK(state->peer_state_ready_); |
549 | | - CHECK(state->peer_state_.load().will_upload); |
| 549 | + if (!state->peer_state_ready_ || !state->peer_state_.load().will_upload) { |
| 550 | + continue; |
| 551 | + } |
550 | 552 | CHECK(state->node_queries_active_.size() < MAX_PEER_TOTAL_QUERIES); |
551 | 553 | auto part_id = part.part_id; |
552 | 554 | if (state->node_queries_active_.insert(static_cast<td::uint32>(part_id)).second) { |
@@ -787,15 +789,21 @@ void NodeActor::db_store_torrent_meta() { |
787 | 789 | return; |
788 | 790 | } |
789 | 791 | next_db_store_meta_at_ = td::Timestamp::never(); |
790 | | - auto meta = torrent_.get_meta_str(); |
791 | | - db_->set(create_hash_tl_object<ton_api::storage_db_key_torrentMeta>(torrent_.get_hash()), td::BufferSlice(meta), |
792 | | - [new_count = (td::int64)torrent_.get_ready_parts_count(), SelfId = actor_id(this)](td::Result<td::Unit> R) { |
793 | | - if (R.is_error()) { |
794 | | - td::actor::send_closure(SelfId, &NodeActor::after_db_store_torrent_meta, R.move_as_error()); |
795 | | - } else { |
796 | | - td::actor::send_closure(SelfId, &NodeActor::after_db_store_torrent_meta, new_count); |
797 | | - } |
798 | | - }); |
| 792 | + auto meta = torrent_.get_meta(); |
| 793 | + delay_action( |
| 794 | + [SelfId = actor_id(this), meta = std::move(meta), db = db_, hash = torrent_.get_hash(), |
| 795 | + new_count = (td::int64)torrent_.get_ready_parts_count()]() { |
| 796 | + auto meta_str = meta.serialize(); |
| 797 | + db->set(create_hash_tl_object<ton_api::storage_db_key_torrentMeta>(hash), td::BufferSlice(meta_str), |
| 798 | + [=](td::Result<td::Unit> R) { |
| 799 | + if (R.is_error()) { |
| 800 | + td::actor::send_closure(SelfId, &NodeActor::after_db_store_torrent_meta, R.move_as_error()); |
| 801 | + } else { |
| 802 | + td::actor::send_closure(SelfId, &NodeActor::after_db_store_torrent_meta, new_count); |
| 803 | + } |
| 804 | + }); |
| 805 | + }, |
| 806 | + td::Timestamp::now()); |
799 | 807 | } |
800 | 808 |
|
801 | 809 | void NodeActor::after_db_store_torrent_meta(td::Result<td::int64> R) { |
|
0 commit comments