Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 11 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
# ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '>$'
Priority: -3
- Regex: '.h>$'
Priority: -2
- Regex: '^\".*/.*\"$'
Priority: -1
- Regex: '^\"[^/]*\"$'
Priority: 0
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
Expand All @@ -70,7 +80,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: false # true
SortIncludes: false # disabled, because we need case insensitive sort
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
Expand Down
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ third_party/** linguist-vendored
*.a binary
*.jar binary
*.tlo binary

*.h merge=clang-format-driver
*.cpp merge=clang-format-driver
*.hpp merge=clang-format-driver
12 changes: 9 additions & 3 deletions .github/workflows/build-ton-linux-x86-64-werror.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Ubuntu TON -Werror build (shared, x86-64)
name: Lint

on: [push, pull_request, workflow_dispatch, workflow_call]

jobs:
build:
lint:
runs-on: ubuntu-24.04

steps:
Expand All @@ -27,7 +27,7 @@ jobs:
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21 clang
sudo ./llvm.sh 21 all

# TODO: Preserve ccache cache between runs once we get rid of warning suppression mappings.

Expand All @@ -41,3 +41,9 @@ jobs:
-DTON_USE_LLD=On \
-DTON_WERROR_BUILD=On
ninja -C build

- name: Check C++ formatting
run: |
# TODO: Run clang-format only on changed files.
clang-format-21 -i $(git ls-files '*.h' '*.hpp' '*.cpp' ':!^example/android/third_party' ':!^tolk/')
git diff --exit-code
9 changes: 5 additions & 4 deletions adnl/adnl-address-list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
Copyright 2017-2020 Telegram Systems LLP
*/
#include "adnl-address-list.hpp"
#include "adnl-peer-table.h"
#include "auto/tl/ton_api.hpp"
#include "td/utils/overloaded.h"
#include "td/net/UdpServer.h"
#include "keys/encryptor.h"
#include "td/net/UdpServer.h"
#include "td/utils/overloaded.h"

#include "adnl-address-list.hpp"
#include "adnl-peer-table.h"

namespace ton {

Expand Down
3 changes: 2 additions & 1 deletion adnl/adnl-address-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/
#pragma once

#include "adnl-network-manager.h"
#include "crypto/common/refcnt.hpp"

#include "adnl-network-manager.h"

namespace ton {

namespace adnl {
Expand Down
2 changes: 1 addition & 1 deletion adnl/adnl-address-list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
#pragma once

#include "adnl-node-id.hpp"
#include "adnl-address-list.h"
#include "adnl-node-id.hpp"

namespace ton {

Expand Down
8 changes: 4 additions & 4 deletions adnl/adnl-channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
Copyright 2017-2020 Telegram Systems LLP
*/
#include "crypto/Ed25519.h"
#include "td/utils/crypto.h"

#include "adnl-channel.hpp"
#include "adnl-peer.h"
#include "adnl-peer-table.h"

#include "td/utils/crypto.h"
#include "crypto/Ed25519.h"
#include "adnl-peer.h"

namespace ton {

Expand Down
4 changes: 2 additions & 2 deletions adnl/adnl-channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#pragma once

#include "adnl-local-id.h"
#include "adnl-peer.h"
#include "adnl-peer-table.h"
#include "adnl-network-manager.h"
#include "adnl-peer-table.h"
#include "adnl-peer.h"

namespace ton {

Expand Down
3 changes: 2 additions & 1 deletion adnl/adnl-channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/
#pragma once

#include "adnl-channel.h"
#include "keys/encryptor.h"

#include "adnl-channel.h"

namespace ton {

namespace adnl {
Expand Down
3 changes: 2 additions & 1 deletion adnl/adnl-db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
Copyright 2017-2020 Telegram Systems LLP
*/
#include "adnl-db.hpp"
#include "td/db/RocksDb.h"

#include "adnl-db.hpp"

namespace ton {

namespace adnl {
Expand Down
3 changes: 2 additions & 1 deletion adnl/adnl-db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/
#pragma once

#include "adnl-db.h"
#include "td/db/KeyValue.h"

#include "adnl-db.h"

namespace ton {

namespace adnl {
Expand Down
2 changes: 1 addition & 1 deletion adnl/adnl-ext-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

Copyright 2017-2020 Telegram Systems LLP
*/
#include "adnl-ext-client.hpp"
#include "adnl-ext-client.h"
#include "adnl-ext-client.hpp"

namespace ton {

Expand Down
3 changes: 2 additions & 1 deletion adnl/adnl-ext-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/
#pragma once

#include "adnl-node-id.hpp"
#include "td/utils/port/IPAddress.h"

#include "adnl-node-id.hpp"

namespace ton {

namespace adnl {
Expand Down
11 changes: 6 additions & 5 deletions adnl/adnl-ext-client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
#pragma once

#include "auto/tl/lite_api.h"
#include "adnl-ext-connection.hpp"
#include "tl-utils/lite-utils.hpp"
#include "td/utils/Random.h"
#include "adnl-query.h"
#include "keys/encryptor.h"
#include "td/utils/Random.h"
#include "tl-utils/lite-utils.hpp"

#include "adnl-ext-client.h"
#include "adnl-ext-connection.hpp"
#include "adnl-query.h"

namespace ton {

Expand Down Expand Up @@ -86,7 +87,7 @@ class AdnlExtClientImpl : public AdnlExtClient {
if (!conn_.empty() && conn_.get() == conn) {
callback_->on_stop_ready();
conn_ = {};
for (auto& q : out_queries_) {
for (auto &q : out_queries_) {
td::actor::send_closure(q.second, &AdnlQuery::set_error, td::Status::Error(ErrorCode::cancelled));
}
alarm_timestamp() = next_create_at_;
Expand Down
12 changes: 6 additions & 6 deletions adnl/adnl-ext-connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
#pragma once

#include <map>
#include <set>

#include "common/errorcode.h"
#include "td/net/TcpListener.h"
#include "td/utils/crypto.h"
#include "td/utils/BufferedFd.h"
#include "tl-utils/tl-utils.hpp"
#include "td/utils/Random.h"
#include "common/errorcode.h"

#include <map>
#include <set>
#include "td/utils/crypto.h"
#include "tl-utils/tl-utils.hpp"

namespace ton {

Expand Down
3 changes: 2 additions & 1 deletion adnl/adnl-ext-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

Copyright 2017-2020 Telegram Systems LLP
*/
#include "adnl-ext-server.hpp"
#include "keys/encryptor.h"

#include "adnl-ext-server.hpp"
#include "utils.hpp"

namespace ton {
Expand Down
11 changes: 6 additions & 5 deletions adnl/adnl-ext-server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
*/
#pragma once

#include "adnl-peer-table.h"
#include <map>
#include <set>

#include "td/net/TcpListener.h"
#include "td/utils/crypto.h"
#include "td/utils/BufferedFd.h"
#include "td/utils/crypto.h"

#include "adnl-ext-connection.hpp"
#include "adnl-ext-server.h"

#include <map>
#include <set>
#include "adnl-peer-table.h"

namespace ton {

Expand Down
7 changes: 3 additions & 4 deletions adnl/adnl-local-id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

Copyright 2017-2020 Telegram Systems LLP
*/
#include "td/utils/crypto.h"
#include "keys/encryptor.h"
#include "td/utils/Random.h"
#include "td/utils/crypto.h"

#include "adnl-local-id.h"
#include "keys/encryptor.h"
#include "utils.hpp"

namespace ton {
Expand All @@ -41,7 +41,7 @@ AdnlAddressList AdnlLocalId::get_addr_list() const {
}

void AdnlLocalId::receive(td::IPAddress addr, td::BufferSlice data) {
InboundRateLimiter& rate_limiter = inbound_rate_limiter_[addr];
InboundRateLimiter &rate_limiter = inbound_rate_limiter_[addr];
if (!rate_limiter.rate_limiter.take()) {
VLOG(ADNL_NOTICE) << this << ": dropping IN message: rate limit exceeded";
add_dropped_packet_stats(addr);
Expand Down Expand Up @@ -371,7 +371,6 @@ tl_object_ptr<ton_api::adnl_stats_localIdPackets> AdnlLocalId::PacketStats::tl(b
return obj;
}


} // namespace adnl

} // namespace ton
7 changes: 3 additions & 4 deletions adnl/adnl-local-id.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@

#include <map>

#include "td/actor/actor.h"
#include "td/utils/BufferedUdp.h"
#include "auto/tl/ton_api.h"
#include "keys/encryptor.h"
#include "adnl-peer-table.h"
#include "dht/dht.h"
#include "keys/encryptor.h"
#include "td/actor/actor.h"
#include "td/utils/BufferedUdp.h"

#include "adnl-peer-table.h"
#include "utils.hpp"
Expand Down
2 changes: 1 addition & 1 deletion adnl/adnl-message.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
#pragma once

#include "adnl/adnl.h"
#include "adnl/adnl-query.h"
#include "adnl/adnl.h"

namespace ton {

Expand Down
7 changes: 3 additions & 4 deletions adnl/adnl-network-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

Copyright 2017-2020 Telegram Systems LLP
*/
#include "adnl-network-manager.hpp"
#include "adnl-peer-table.h"

#include "auto/tl/ton_api.hpp"

#include "td/utils/overloaded.h"

#include "adnl-network-manager.hpp"
#include "adnl-peer-table.h"

namespace ton {

namespace adnl {
Expand Down
5 changes: 2 additions & 3 deletions adnl/adnl-network-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@
*/
#pragma once

#include "td/actor/actor.h"
#include <bitset>

#include "td/actor/PromiseFuture.h"
#include "td/actor/actor.h"
#include "td/utils/port/IPAddress.h"

#include "adnl-node-id.hpp"
#include "adnl-proxy-types.h"

#include <bitset>

namespace td {
class UdpServer;
}
Expand Down
10 changes: 5 additions & 5 deletions adnl/adnl-network-manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
*/
#pragma once

#include <map>

#include "td/actor/PromiseFuture.h"
#include "td/actor/actor.h"
#include "td/utils/BufferedUdp.h"
#include "td/net/UdpServer.h"
#include "td/net/TcpListener.h"
#include "td/net/UdpServer.h"
#include "td/utils/BufferedUdp.h"

#include "td/actor/PromiseFuture.h"
#include "adnl-network-manager.h"
#include "adnl-received-mask.h"

#include <map>

namespace td {
class UdpServer;
}
Expand Down
Loading
Loading