|
16 | 16 |
|
17 | 17 | Copyright 2019-2020 Telegram Systems LLP |
18 | 18 | */ |
19 | | -#include "archive-slice.hpp" |
| 19 | +#include <csignal> |
20 | 20 |
|
| 21 | +#include "common/delay.h" |
21 | 22 | #include "td/actor/MultiPromise.h" |
22 | | -#include "validator/fabric.h" |
23 | 23 | #include "td/db/RocksDb.h" |
24 | | -#include "td/utils/port/path.h" |
25 | | -#include "common/delay.h" |
26 | | -#include "files-async.hpp" |
27 | | -#include "db-utils.h" |
28 | 24 | #include "td/utils/PathView.h" |
29 | 25 | #include "td/utils/Random.h" |
| 26 | +#include "td/utils/port/path.h" |
| 27 | +#include "validator/fabric.h" |
30 | 28 |
|
31 | | -#include <csignal> |
| 29 | +#include "archive-slice.hpp" |
| 30 | +#include "db-utils.h" |
| 31 | +#include "files-async.hpp" |
32 | 32 |
|
33 | 33 | namespace ton { |
34 | 34 |
|
35 | 35 | namespace validator { |
36 | 36 |
|
37 | 37 | class PackageStatistics { |
38 | | - public: |
| 38 | + public: |
39 | 39 | void record_open(uint64_t count = 1) { |
40 | 40 | open_count.fetch_add(count, std::memory_order_relaxed); |
41 | 41 | } |
@@ -86,7 +86,7 @@ class PackageStatistics { |
86 | 86 | return ss.str(); |
87 | 87 | } |
88 | 88 |
|
89 | | - private: |
| 89 | + private: |
90 | 90 | std::atomic_uint64_t open_count{0}; |
91 | 91 | std::atomic_uint64_t close_count{0}; |
92 | 92 | PercentileStats read_time; |
@@ -162,16 +162,20 @@ void PackageWriter::sync_now() { |
162 | 162 | if (!waiters.empty()) { |
163 | 163 | LOG(DEBUG) << "Writer huge transaction size = " << waiters.size(); |
164 | 164 | } |
165 | | - for (auto &promise: waiters) { |
| 165 | + for (auto &promise : waiters) { |
166 | 166 | promise.set_value(td::Unit{}); |
167 | 167 | } |
168 | 168 | } |
169 | 169 |
|
170 | 170 | class PackageReader : public td::actor::Actor { |
171 | 171 | public: |
172 | 172 | PackageReader(std::shared_ptr<Package> package, td::uint64 offset, |
173 | | - td::Promise<std::pair<std::string, td::BufferSlice>> promise, std::shared_ptr<PackageStatistics> statistics) |
174 | | - : package_(std::move(package)), offset_(offset), promise_(std::move(promise)), statistics_(std::move(statistics)) { |
| 173 | + td::Promise<std::pair<std::string, td::BufferSlice>> promise, |
| 174 | + std::shared_ptr<PackageStatistics> statistics) |
| 175 | + : package_(std::move(package)) |
| 176 | + , offset_(offset) |
| 177 | + , promise_(std::move(promise)) |
| 178 | + , statistics_(std::move(statistics)) { |
175 | 179 | } |
176 | 180 | void start_up() override { |
177 | 181 | auto start = td::Timestamp::now(); |
@@ -555,14 +559,14 @@ void ArchiveSlice::get_block_by_seqno(AccountIdPrefixFull account_id, BlockSeqno |
555 | 559 | return get_block_common( |
556 | 560 | account_id, |
557 | 561 | [seqno](ton_api::db_lt_desc_value &w) { |
558 | | - return seqno > static_cast<BlockSeqno>(w.last_seqno_) |
559 | | - ? 1 |
560 | | - : seqno == static_cast<BlockSeqno>(w.last_seqno_) ? 0 : -1; |
| 562 | + return seqno > static_cast<BlockSeqno>(w.last_seqno_) ? 1 |
| 563 | + : seqno == static_cast<BlockSeqno>(w.last_seqno_) ? 0 |
| 564 | + : -1; |
561 | 565 | }, |
562 | 566 | [seqno](ton_api::db_lt_el_value &w) { |
563 | | - return seqno > static_cast<BlockSeqno>(w.id_->seqno_) |
564 | | - ? 1 |
565 | | - : seqno == static_cast<BlockSeqno>(w.id_->seqno_) ? 0 : -1; |
| 567 | + return seqno > static_cast<BlockSeqno>(w.id_->seqno_) ? 1 |
| 568 | + : seqno == static_cast<BlockSeqno>(w.id_->seqno_) ? 0 |
| 569 | + : -1; |
566 | 570 | }, |
567 | 571 | true, std::move(promise)); |
568 | 572 | } |
@@ -768,7 +772,7 @@ void ArchiveSlice::do_close() { |
768 | 772 | id_to_package_.clear(); |
769 | 773 | } |
770 | 774 |
|
771 | | -template<typename T> |
| 775 | +template <typename T> |
772 | 776 | td::Promise<T> ArchiveSlice::begin_async_query(td::Promise<T> promise) { |
773 | 777 | ++active_queries_; |
774 | 778 | return [SelfId = actor_id(this), promise = std::move(promise)](td::Result<T> R) mutable { |
@@ -818,12 +822,11 @@ void ArchiveSlice::commit_transaction_now() { |
818 | 822 | if (!waiters.empty()) { |
819 | 823 | LOG(DEBUG) << "Huge transaction size = " << waiters.size(); |
820 | 824 | } |
821 | | - for (auto &promise: waiters) { |
| 825 | + for (auto &promise : waiters) { |
822 | 826 | promise.set_value(td::Unit{}); |
823 | 827 | } |
824 | 828 | } |
825 | 829 |
|
826 | | - |
827 | 830 | void ArchiveSlice::set_async_mode(bool mode, td::Promise<td::Unit> promise) { |
828 | 831 | async_mode_ = mode; |
829 | 832 | if (!async_mode_) { |
@@ -1097,7 +1100,7 @@ void ArchiveSlice::truncate(BlockSeqno masterchain_seqno, ConstBlockHandle, td:: |
1097 | 1100 | return; |
1098 | 1101 | } |
1099 | 1102 |
|
1100 | | - std::map<ShardIdFull, PackageInfo*> old_packages; |
| 1103 | + std::map<ShardIdFull, PackageInfo *> old_packages; |
1101 | 1104 | std::map<ShardIdFull, std::shared_ptr<Package>> new_packages; |
1102 | 1105 |
|
1103 | 1106 | std::string value; |
@@ -1138,7 +1141,7 @@ void ArchiveSlice::truncate(BlockSeqno masterchain_seqno, ConstBlockHandle, td:: |
1138 | 1141 | truncate_shard(masterchain_seqno, shard, package->seqno, new_packages[package->shard_prefix].get()); |
1139 | 1142 | } |
1140 | 1143 |
|
1141 | | - for (auto& [shard_prefix, package] : old_packages) { |
| 1144 | + for (auto &[shard_prefix, package] : old_packages) { |
1142 | 1145 | auto new_package = new_packages[shard_prefix]; |
1143 | 1146 | CHECK(new_package); |
1144 | 1147 | package->package = new_package; |
|
0 commit comments