Skip to content

Commit a345d37

Browse files
committed
Reformat code
1 parent ce6ae3a commit a345d37

23 files changed

+229
-233
lines changed

crypto/vm/boc-compression.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@
1616
1717
Copyright 2017-2020 Telegram Systems LLP
1818
*/
19-
#include "boc-compression.h"
20-
2119
#include <algorithm>
2220
#include <bitset>
23-
#include "vm/boc.h"
24-
#include "vm/boc-writers.h"
25-
#include "vm/cells.h"
26-
#include "vm/cellslice.h"
21+
2722
#include "td/utils/Slice-decl.h"
2823
#include "td/utils/lz4.h"
2924
#include "ton/ton-types.h"
25+
#include "vm/boc-writers.h"
26+
#include "vm/boc.h"
27+
#include "vm/cells.h"
28+
#include "vm/cellslice.h"
29+
30+
#include "boc-compression.h"
3031

3132
namespace vm {
3233

@@ -43,7 +44,8 @@ td::Result<td::BufferSlice> boc_compress_baseline_lz4(const std::vector<td::Ref<
4344
return compressed_with_size;
4445
}
4546

46-
td::Result<std::vector<td::Ref<vm::Cell>>> boc_decompress_baseline_lz4(td::Slice compressed, int max_decompressed_size) {
47+
td::Result<std::vector<td::Ref<vm::Cell>>> boc_decompress_baseline_lz4(td::Slice compressed,
48+
int max_decompressed_size) {
4749
// Check minimum input size for decompressed size header
4850
if (compressed.size() < kDecompressedSizeBytes) {
4951
return td::Status::Error("BOC decompression failed: input too small for header");
@@ -284,7 +286,7 @@ td::Result<td::BufferSlice> boc_compress_improved_structure_lz4(const std::vecto
284286
if (rank[boc_graph[node][j]] <= i + 1)
285287
continue;
286288

287-
int delta = rank[boc_graph[node][j]] - i - 2; // Always >= 0 because of above check
289+
int delta = rank[boc_graph[node][j]] - i - 2; // Always >= 0 because of above check
288290
size_t required_bits = 1 + (31 ^ td::count_leading_zeroes32(node_count - i - 3));
289291

290292
if (required_bits < 8 - (result.size() + 1) % 8 + 1) {
@@ -341,7 +343,8 @@ td::Result<td::BufferSlice> boc_compress_improved_structure_lz4(const std::vecto
341343
return compressed_with_size;
342344
}
343345

344-
td::Result<std::vector<td::Ref<vm::Cell>>> boc_decompress_improved_structure_lz4(td::Slice compressed, int max_decompressed_size) {
346+
td::Result<std::vector<td::Ref<vm::Cell>>> boc_decompress_improved_structure_lz4(td::Slice compressed,
347+
int max_decompressed_size) {
345348
constexpr size_t kMaxCellDataLengthBits = 1024;
346349

347350
// Check minimum input size for decompressed size header
@@ -393,7 +396,6 @@ td::Result<std::vector<td::Ref<vm::Cell>>> boc_decompress_improved_structure_lz4
393396
return td::Status::Error("BOC decompression failed: incorrect node count provided");
394397
}
395398

396-
397399
// Validate root indexes
398400
for (int i = 0; i < root_count; ++i) {
399401
if (root_indexes[i] >= node_count) {
@@ -597,7 +599,7 @@ td::Result<td::BufferSlice> boc_compress(const std::vector<td::Ref<vm::Cell>>& b
597599
} else if (algo == CompressionAlgorithm::ImprovedStructureLZ4) {
598600
TRY_RESULT_ASSIGN(compressed, boc_compress_improved_structure_lz4(boc_roots));
599601
} else {
600-
return td::Status::Error("Unknown compression algorithm");
602+
return td::Status::Error("Unknown compression algorithm");
601603
}
602604

603605
td::BufferSlice compressed_with_algo(compressed.size() + 1);

crypto/vm/boc.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616
1717
Copyright 2017-2020 Telegram Systems LLP
1818
*/
19-
#include <iostream>
20-
#include <iomanip>
2119
#include <algorithm>
22-
#include "vm/boc.h"
20+
#include <iomanip>
21+
#include <iostream>
2322

2423
#include "cells/MerkleProof.h"
2524
#include "cells/PrunnedCell.h"
26-
#include "vm/boc-writers.h"
27-
#include "vm/cells.h"
28-
#include "vm/cellslice.h"
25+
#include "td/utils/Slice-decl.h"
2926
#include "td/utils/bits.h"
3027
#include "td/utils/crypto.h"
3128
#include "td/utils/format.h"
3229
#include "td/utils/misc.h"
33-
#include "td/utils/Slice-decl.h"
30+
#include "vm/boc-writers.h"
31+
#include "vm/boc.h"
32+
#include "vm/cells.h"
33+
#include "vm/cellslice.h"
3434

3535
namespace vm {
3636
using td::Ref;
@@ -1160,7 +1160,7 @@ td::Result<CellStorageStat::CellInfo> CellStorageStat::add_used_storage(Ref<vm::
11601160
}
11611161

11621162
td::Result<CellStorageStat::CellInfo> CellStorageStat::add_used_storage(td::Span<Ref<Cell>> cells, bool kill_dup,
1163-
unsigned skip_count_root) {
1163+
unsigned skip_count_root) {
11641164
CellInfo result;
11651165
for (const auto& cell : cells) {
11661166
TRY_RESULT(info, add_used_storage(cell, kill_dup, skip_count_root));

tdutils/td/utils/LRUCache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ class LRUCache {
9797
cache_.erase(it);
9898
}
9999

100-
101100
private:
102101
struct Entry : ListNode {
103102
Entry(K key, uint64 weight) : key(std::move(key)), weight(weight) {

validator-session/candidate-serializer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
You should have received a copy of the GNU Lesser General Public License
1515
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
1616
*/
17-
#include "candidate-serializer.h"
18-
#include "tl-utils/tl-utils.hpp"
19-
#include "vm/boc.h"
2017
#include "td/utils/lz4.h"
18+
#include "tl-utils/tl-utils.hpp"
2119
#include "vm/boc-compression.h"
20+
#include "vm/boc.h"
21+
22+
#include "candidate-serializer.h"
2223
#include "validator-session-types.h"
2324

2425
namespace ton::validatorsession {

validator-session/validator-session.cpp

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
1717
Copyright 2017-2020 Telegram Systems LLP
1818
*/
19-
#include "validator-session.hpp"
2019
#include "td/utils/Random.h"
21-
#include "candidate-serializer.h"
22-
#include "delay.h"
2320
#include "td/utils/overloaded.h"
2421
#include "ton/ton-tl.hpp"
2522

23+
#include "candidate-serializer.h"
24+
#include "delay.h"
25+
#include "validator-session.hpp"
26+
2627
namespace ton {
2728

2829
namespace validatorsession {
@@ -209,7 +210,7 @@ void ValidatorSessionImpl::preprocess_block(catchain::CatChainBlock *block) {
209210
}
210211

211212
bool ValidatorSessionImpl::ensure_candidate_unique(td::uint32 src_idx, td::uint32 round,
212-
ValidatorSessionCandidateId block_id) {
213+
ValidatorSessionCandidateId block_id) {
213214
auto it = src_round_candidate_[src_idx].find(round);
214215
if (it != src_round_candidate_[src_idx].end() && it->second != block_id) {
215216
VLOG(VALIDATOR_SESSION_WARNING) << this << "[node " << description_->get_source_adnl_id(src_idx) << "][candidate "
@@ -770,8 +771,8 @@ void ValidatorSessionImpl::try_approve_block(const SentBlock *block) {
770771
td::actor::send_closure(SelfId, &ValidatorSessionImpl::candidate_decision_ok, round, hash, root_hash,
771772
file_hash, src, R.ok_from(), timer.elapsed(), R.is_cached());
772773
} else {
773-
td::actor::send_closure(SelfId, &ValidatorSessionImpl::candidate_decision_fail, round, hash, R.reason(),
774-
src, R.proof(), timer.elapsed(), R.is_cached());
774+
td::actor::send_closure(SelfId, &ValidatorSessionImpl::candidate_decision_fail, round, hash, R.reason(), src,
775+
R.proof(), timer.elapsed(), R.is_cached());
775776
}
776777
});
777778
pending_approve_.insert(block_id);
@@ -1045,7 +1046,6 @@ void ValidatorSessionImpl::store_block_candidate(ValidatorSessionCandidateId can
10451046
}
10461047
}
10471048

1048-
10491049
void ValidatorSessionImpl::request_new_block(bool now) {
10501050
if (requested_new_block_now_) {
10511051
return;
@@ -1269,9 +1269,9 @@ void ValidatorSessionImpl::start() {
12691269

12701270
auto w = description().export_catchain_nodes();
12711271

1272-
catchain_ = catchain::CatChain::create(
1273-
make_catchain_callback(), description().opts().catchain_opts, keyring_, adnl_, overlay_manager_, std::move(w),
1274-
local_id(), unique_hash_, db_root_, db_suffix_, allow_unsafe_self_blocks_resync_);
1272+
catchain_ = catchain::CatChain::create(make_catchain_callback(), description().opts().catchain_opts, keyring_, adnl_,
1273+
overlay_manager_, std::move(w), local_id(), unique_hash_, db_root_, db_suffix_,
1274+
allow_unsafe_self_blocks_resync_);
12751275

12761276
check_all();
12771277
}
@@ -1408,14 +1408,14 @@ void ValidatorSessionImpl::stats_init() {
14081408
cur_stats_.total_weight = description().get_total_weight();
14091409
cur_stats_.self = description().get_source_id(local_idx());
14101410

1411-
for (auto it = stats_pending_approve_.begin(); it != stats_pending_approve_.end(); ) {
1411+
for (auto it = stats_pending_approve_.begin(); it != stats_pending_approve_.end();) {
14121412
if (it->first.first < cur_round_) {
14131413
it = stats_pending_approve_.erase(it);
14141414
} else {
14151415
++it;
14161416
}
14171417
}
1418-
for (auto it = stats_pending_sign_.begin(); it != stats_pending_sign_.end(); ) {
1418+
for (auto it = stats_pending_sign_.begin(); it != stats_pending_sign_.end();) {
14191419
if (it->first.first < cur_round_) {
14201420
it = stats_pending_sign_.erase(it);
14211421
} else {
@@ -1433,7 +1433,7 @@ void ValidatorSessionImpl::stats_init() {
14331433
void ValidatorSessionImpl::stats_add_round() {
14341434
td::uint32 round = cur_stats_.first_round + cur_stats_.rounds.size();
14351435
cur_stats_.rounds.emplace_back();
1436-
auto& stat = cur_stats_.rounds.back();
1436+
auto &stat = cur_stats_.rounds.back();
14371437
stat.producers.resize(description().get_max_priority() + 1);
14381438
for (td::uint32 i = 0; i < description().get_total_nodes(); i++) {
14391439
td::int32 priority = description().get_node_priority(i, round);
@@ -1502,38 +1502,38 @@ ValidatorSessionStats::Producer *ValidatorSessionImpl::stats_get_candidate_stat_
15021502
}
15031503

15041504
void ValidatorSessionImpl::stats_process_action(td::uint32 node_id, ton_api::validatorSession_round_Message &action) {
1505-
ton_api::downcast_call(action, td::overloaded(
1506-
[&](const ton_api::validatorSession_message_submittedBlock &obj) {
1507-
auto candidate_id = description().candidate_id(
1508-
node_id, obj.root_hash_, obj.file_hash_, obj.collated_data_file_hash_);
1509-
auto stat = stats_get_candidate_stat(
1510-
obj.round_, description().get_source_id(node_id), candidate_id);
1511-
if (stat && stat->got_submit_at <= 0.0) {
1512-
stat->got_submit_at = td::Clocks::system();
1513-
stat->block_id.root_hash = obj.root_hash_;
1514-
stat->block_id.file_hash = obj.file_hash_;
1515-
stat->collated_data_hash = obj.collated_data_file_hash_;
1516-
}
1517-
},
1518-
[&](const ton_api::validatorSession_message_approvedBlock &obj) {
1519-
if (obj.candidate_ == skip_round_candidate_id()) {
1520-
return;
1521-
}
1522-
process_approve(node_id, obj.round_, obj.candidate_);
1523-
},
1524-
[&](const ton_api::validatorSession_message_commit &obj) {
1525-
if (obj.candidate_ == skip_round_candidate_id()) {
1526-
return;
1527-
}
1528-
auto stat = stats_get_candidate_stat_by_id(obj.round_, obj.candidate_);
1529-
if (stat) {
1530-
stat->set_signed_by(node_id, description().get_node_weight(node_id),
1531-
description().get_total_weight());
1532-
} else {
1533-
stats_pending_sign_[{obj.round_, obj.candidate_}].push_back(node_id);
1534-
}
1535-
},
1536-
[](const auto &) {}));
1505+
ton_api::downcast_call(
1506+
action,
1507+
td::overloaded(
1508+
[&](const ton_api::validatorSession_message_submittedBlock &obj) {
1509+
auto candidate_id =
1510+
description().candidate_id(node_id, obj.root_hash_, obj.file_hash_, obj.collated_data_file_hash_);
1511+
auto stat = stats_get_candidate_stat(obj.round_, description().get_source_id(node_id), candidate_id);
1512+
if (stat && stat->got_submit_at <= 0.0) {
1513+
stat->got_submit_at = td::Clocks::system();
1514+
stat->block_id.root_hash = obj.root_hash_;
1515+
stat->block_id.file_hash = obj.file_hash_;
1516+
stat->collated_data_hash = obj.collated_data_file_hash_;
1517+
}
1518+
},
1519+
[&](const ton_api::validatorSession_message_approvedBlock &obj) {
1520+
if (obj.candidate_ == skip_round_candidate_id()) {
1521+
return;
1522+
}
1523+
process_approve(node_id, obj.round_, obj.candidate_);
1524+
},
1525+
[&](const ton_api::validatorSession_message_commit &obj) {
1526+
if (obj.candidate_ == skip_round_candidate_id()) {
1527+
return;
1528+
}
1529+
auto stat = stats_get_candidate_stat_by_id(obj.round_, obj.candidate_);
1530+
if (stat) {
1531+
stat->set_signed_by(node_id, description().get_node_weight(node_id), description().get_total_weight());
1532+
} else {
1533+
stats_pending_sign_[{obj.round_, obj.candidate_}].push_back(node_id);
1534+
}
1535+
},
1536+
[](const auto &) {}));
15371537
}
15381538

15391539
void ValidatorSessionImpl::process_approve(td::uint32 node_id, td::uint32 round,

validator-session/validator-session.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ class ValidatorSession : public td::actor::Actor {
113113
td::Promise<std::vector<tl_object_ptr<lite_api::liteServer_nonfinal_candidateInfo>>> promise) = 0;
114114
virtual void set_catchain_max_block_delay(double delay, double delay_slow) = 0;
115115
virtual void get_accepted_candidate(PublicKey source, BlockIdExt block_id,
116-
ValidatorSessionCollatedDataFileHash collated_data_file_hash,
117-
td::Promise<BlockCandidate> promise) = 0;
116+
ValidatorSessionCollatedDataFileHash collated_data_file_hash,
117+
td::Promise<BlockCandidate> promise) = 0;
118118

119119
static td::actor::ActorOwn<ValidatorSession> create(
120120
catchain::CatChainSessionId session_id, ValidatorSessionOptions opts, PublicKeyHash local_id,

validator-session/validator-session.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ class ValidatorSessionImpl : public ValidatorSession {
234234
catchain_max_block_delay_slow_ = delay_slow;
235235
}
236236
void get_accepted_candidate(PublicKey source, BlockIdExt block_id,
237-
ValidatorSessionCollatedDataFileHash collated_data_file_hash,
238-
td::Promise<BlockCandidate> promise) override;
237+
ValidatorSessionCollatedDataFileHash collated_data_file_hash,
238+
td::Promise<BlockCandidate> promise) override;
239239

240240
void process_blocks(std::vector<catchain::CatChainBlock *> blocks);
241241
void finished_processing();

validator/collation-manager.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
*/
1717
#pragma once
1818

19-
#include "fabric.h"
19+
#include <map>
20+
2021
#include "interfaces/validator-manager.h"
2122
#include "rldp2/rldp.h"
22-
#include <map>
23+
24+
#include "fabric.h"
2325

2426
namespace ton::validator {
2527

validator/collator-node/collator-node-session.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
#include "collator-node-session.hpp"
19-
2018
#include "block-auto.h"
2119
#include "checksum.h"
20+
#include "collator-node-session.hpp"
2221
#include "collator-node.hpp"
2322
#include "fabric.h"
2423
#include "full-node.h"
@@ -443,7 +442,6 @@ void CollatorNodeSession::process_accepted_block_cont2(Ref<BlockData> block) {
443442
process_accepted_block(prev[0]);
444443
}
445444

446-
447445
void CollatorNodeSession::wait_collated_data_merged(BlockSeqno seqno, td::Timestamp timeout,
448446
td::Promise<td::Unit> promise) {
449447
if (!merge_collated_data_enabled_ || collated_data_merged_upto_ >= seqno) {

validator/collator-node/collator-node-session.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
*/
1717
#pragma once
1818

19+
#include <map>
20+
#include <optional>
21+
1922
#include "impl/collated-data-merger.h"
2023
#include "interfaces/validator-manager.h"
2124
#include "rldp/rldp.h"
2225
#include "rldp2/rldp.h"
23-
#include <map>
24-
#include <optional>
2526

2627
namespace ton::validator {
2728

0 commit comments

Comments
 (0)