Minor improvements.
This commit is contained in:
parent
1ebf835ac5
commit
9f44816a62
@ -11,6 +11,7 @@
|
|||||||
#include "td/telegram/ServerMessageId.h"
|
#include "td/telegram/ServerMessageId.h"
|
||||||
#include "td/telegram/UserId.h"
|
#include "td/telegram/UserId.h"
|
||||||
|
|
||||||
|
#include "td/db/DbKey.h"
|
||||||
#include "td/db/SqliteConnectionSafe.h"
|
#include "td/db/SqliteConnectionSafe.h"
|
||||||
#include "td/db/SqliteDb.h"
|
#include "td/db/SqliteDb.h"
|
||||||
|
|
||||||
|
@ -4197,7 +4197,7 @@ deleteChatHistory chat_id:int53 remove_from_chat_list:Bool revoke:Bool = Ok;
|
|||||||
deleteChat chat_id:int53 = Ok;
|
deleteChat chat_id:int53 = Ok;
|
||||||
|
|
||||||
//@description Searches for messages with given words in the chat. Returns the results in reverse chronological order, i.e. in order of decreasing message_id. Cannot be used in secret chats with a non-empty query
|
//@description Searches for messages with given words in the chat. Returns the results in reverse chronological order, i.e. in order of decreasing message_id. Cannot be used in secret chats with a non-empty query
|
||||||
//-(searchSecretMessages mmust be used instead), or without an enabled message database. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
|
//-(searchSecretMessages must be used instead), or without an enabled message database. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
|
||||||
//@chat_id Identifier of the chat in which to search messages
|
//@chat_id Identifier of the chat in which to search messages
|
||||||
//@query Query to search for
|
//@query Query to search for
|
||||||
//@sender Sender of messages to search for; pass null to search for messages from any sender. Not supported in secret chats
|
//@sender Sender of messages to search for; pass null to search for messages from any sender. Not supported in secret chats
|
||||||
@ -4725,7 +4725,7 @@ addChatMember chat_id:int53 user_id:int53 forward_limit:int32 = Ok;
|
|||||||
//@chat_id Chat identifier @user_ids Identifiers of the users to be added to the chat. The maximum number of added users is 20 for supergroups and 100 for channels
|
//@chat_id Chat identifier @user_ids Identifiers of the users to be added to the chat. The maximum number of added users is 20 for supergroups and 100 for channels
|
||||||
addChatMembers chat_id:int53 user_ids:vector<int53> = Ok;
|
addChatMembers chat_id:int53 user_ids:vector<int53> = Ok;
|
||||||
|
|
||||||
//@description Changes the status of a chat member, needs appropriate privileges. This function is currently not suitable for transferring chat ownership; use transferChatOwnership instead. Use addChatMember or banChatMember if you need to pass some additional parameters
|
//@description Changes the status of a chat member, needs appropriate privileges. This function is currently not suitable for transferring chat ownership; use transferChatOwnership instead. Use addChatMember or banChatMember if some additional parameters needs to be passed
|
||||||
//@chat_id Chat identifier @member_id Member identifier. Chats can be only banned and unbanned in supergroups and channels @status The new status of the member in the chat
|
//@chat_id Chat identifier @member_id Member identifier. Chats can be only banned and unbanned in supergroups and channels @status The new status of the member in the chat
|
||||||
setChatMemberStatus chat_id:int53 member_id:MessageSender status:ChatMemberStatus = Ok;
|
setChatMemberStatus chat_id:int53 member_id:MessageSender status:ChatMemberStatus = Ok;
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ std::string TD_TL_writer_jni_cpp::gen_type_fetch(const std::string &field_name,
|
|||||||
|
|
||||||
if (!(tree_type->flags & tl::FLAG_BARE)) {
|
if (!(tree_type->flags & tl::FLAG_BARE)) {
|
||||||
if (is_type_bare(t)) {
|
if (is_type_bare(t)) {
|
||||||
if (field_name != "") {
|
if (!field_name.empty()) {
|
||||||
std::fprintf(stderr, "Do not use non-bare fields with bare type %s\n", name.c_str());
|
std::fprintf(stderr, "Do not use non-bare fields with bare type %s\n", name.c_str());
|
||||||
// assert(false);
|
// assert(false);
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ std::string TD_TL_writer_jni_cpp::gen_type_fetch(const std::string &field_name,
|
|||||||
const tl::tl_tree_type *child = static_cast<const tl::tl_tree_type *>(tree_type->children[0]);
|
const tl::tl_tree_type *child = static_cast<const tl::tl_tree_type *>(tree_type->children[0]);
|
||||||
res = gen_vector_fetch(field_name, child, vars, parser_type);
|
res = gen_vector_fetch(field_name, child, vars, parser_type);
|
||||||
} else {
|
} else {
|
||||||
if (field_name == "") {
|
if (field_name.empty()) {
|
||||||
return gen_main_class_name(tree_type->type) + "::fetch(env, p)";
|
return gen_main_class_name(tree_type->type) + "::fetch(env, p)";
|
||||||
}
|
}
|
||||||
res = "jni::fetch_tl_object<" + gen_main_class_name(tree_type->type) + ">(env, jni::fetch_object(env, p, " +
|
res = "jni::fetch_tl_object<" + gen_main_class_name(tree_type->type) + ">(env, jni::fetch_object(env, p, " +
|
||||||
@ -565,14 +565,14 @@ std::string TD_TL_writer_jni_cpp::gen_additional_function(const std::string &fun
|
|||||||
" " +
|
" " +
|
||||||
class_name_class + " = jni::get_jclass(env, " + gen_java_class_name(gen_class_name(t->name)) + ");\n";
|
class_name_class + " = jni::get_jclass(env, " + gen_java_class_name(gen_class_name(t->name)) + ");\n";
|
||||||
|
|
||||||
if (t->args.size()) {
|
if (!t->args.empty()) {
|
||||||
for (std::size_t i = 0; i < t->args.size(); i++) {
|
for (std::size_t i = 0; i < t->args.size(); i++) {
|
||||||
const tl::arg &a = t->args[i];
|
const tl::arg &a = t->args[i];
|
||||||
assert(a.type->get_type() == tl::NODE_TYPE_TYPE);
|
assert(a.type->get_type() == tl::NODE_TYPE_TYPE);
|
||||||
const tl::tl_tree_type *tree_type = static_cast<tl::tl_tree_type *>(a.type);
|
const tl::tl_tree_type *tree_type = static_cast<tl::tl_tree_type *>(a.type);
|
||||||
|
|
||||||
std::string field_name = gen_field_name(a.name);
|
std::string field_name = gen_field_name(a.name);
|
||||||
assert(field_name.size());
|
assert(!field_name.empty());
|
||||||
std::string java_field_name = gen_java_field_name(std::string(field_name, 0, field_name.size() - 1));
|
std::string java_field_name = gen_java_field_name(std::string(field_name, 0, field_name.size() - 1));
|
||||||
|
|
||||||
std::string type_signature = gen_type_signature(tree_type);
|
std::string type_signature = gen_type_signature(tree_type);
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/Slice.h"
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace mtproto {
|
namespace mtproto {
|
||||||
|
@ -453,9 +453,10 @@ class RawConnectionHttp final : public RawConnection {
|
|||||||
unique_ptr<RawConnection> RawConnection::create(IPAddress ip_address, SocketFd socket_fd, TransportType transport_type,
|
unique_ptr<RawConnection> RawConnection::create(IPAddress ip_address, SocketFd socket_fd, TransportType transport_type,
|
||||||
unique_ptr<StatsCallback> stats_callback) {
|
unique_ptr<StatsCallback> stats_callback) {
|
||||||
#if TD_DARWIN_WATCH_OS
|
#if TD_DARWIN_WATCH_OS
|
||||||
return td::make_unique<RawConnectionHttp>(ip_address, std::move(stats_callback));
|
return td::make_unique<RawConnectionHttp>(std::move(ip_address), std::move(stats_callback));
|
||||||
#else
|
#else
|
||||||
return td::make_unique<RawConnectionDefault>(std::move(socket_fd), transport_type, std::move(stats_callback));
|
return td::make_unique<RawConnectionDefault>(std::move(socket_fd), std::move(transport_type),
|
||||||
|
std::move(stats_callback));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/Random.h"
|
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
#include "td/utils/buffer.h"
|
#include "td/utils/buffer.h"
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
class Td;
|
class Td;
|
||||||
|
@ -16,7 +16,7 @@ namespace td {
|
|||||||
|
|
||||||
ClientActor::ClientActor(unique_ptr<TdCallback> callback, Options options) {
|
ClientActor::ClientActor(unique_ptr<TdCallback> callback, Options options) {
|
||||||
Td::Options td_options;
|
Td::Options td_options;
|
||||||
td_options.net_query_stats = options.net_query_stats;
|
td_options.net_query_stats = std::move(options.net_query_stats);
|
||||||
td_ = create_actor<Td>("Td", std::move(callback), std::move(td_options));
|
td_ = create_actor<Td>("Td", std::move(callback), std::move(td_options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/FloodControlStrict.h"
|
#include "td/utils/FloodControlStrict.h"
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/port/IPAddress.h"
|
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
|
@ -1308,17 +1308,17 @@ class ContactsManager final : public Actor {
|
|||||||
void load_secret_chat_from_database_impl(SecretChatId secret_chat_id, Promise<Unit> promise);
|
void load_secret_chat_from_database_impl(SecretChatId secret_chat_id, Promise<Unit> promise);
|
||||||
void on_load_secret_chat_from_database(SecretChatId secret_chat_id, string value, bool force);
|
void on_load_secret_chat_from_database(SecretChatId secret_chat_id, string value, bool force);
|
||||||
|
|
||||||
void save_user_full(const UserFull *user_full, UserId user_id);
|
static void save_user_full(const UserFull *user_full, UserId user_id);
|
||||||
static string get_user_full_database_key(UserId user_id);
|
static string get_user_full_database_key(UserId user_id);
|
||||||
static string get_user_full_database_value(const UserFull *user_full);
|
static string get_user_full_database_value(const UserFull *user_full);
|
||||||
void on_load_user_full_from_database(UserId user_id, string value);
|
void on_load_user_full_from_database(UserId user_id, string value);
|
||||||
|
|
||||||
void save_chat_full(const ChatFull *chat_full, ChatId chat_id);
|
static void save_chat_full(const ChatFull *chat_full, ChatId chat_id);
|
||||||
static string get_chat_full_database_key(ChatId chat_id);
|
static string get_chat_full_database_key(ChatId chat_id);
|
||||||
static string get_chat_full_database_value(const ChatFull *chat_full);
|
static string get_chat_full_database_value(const ChatFull *chat_full);
|
||||||
void on_load_chat_full_from_database(ChatId chat_id, string value);
|
void on_load_chat_full_from_database(ChatId chat_id, string value);
|
||||||
|
|
||||||
void save_channel_full(const ChannelFull *channel_full, ChannelId channel_id);
|
static void save_channel_full(const ChannelFull *channel_full, ChannelId channel_id);
|
||||||
static string get_channel_full_database_key(ChannelId channel_id);
|
static string get_channel_full_database_key(ChannelId channel_id);
|
||||||
static string get_channel_full_database_value(const ChannelFull *channel_full);
|
static string get_channel_full_database_value(const ChannelFull *channel_full);
|
||||||
void on_load_channel_full_from_database(ChannelId channel_id, string value, const char *source);
|
void on_load_channel_full_from_database(ChannelId channel_id, string value, const char *source);
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
#include "td/telegram/Global.h"
|
#include "td/telegram/Global.h"
|
||||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||||
|
|
||||||
#include "td/utils/Status.h"
|
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
void DelayDispatcher::send_with_callback(NetQueryPtr query, ActorShared<NetQueryCallback> callback) {
|
void DelayDispatcher::send_with_callback(NetQueryPtr query, ActorShared<NetQueryCallback> callback) {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/misc.h"
|
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "td/telegram/DialogId.h"
|
||||||
#include "td/telegram/InputMessageText.h"
|
#include "td/telegram/InputMessageText.h"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
#include "td/telegram/td_api.h"
|
#include "td/telegram/td_api.h"
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "td/telegram/StickerSetId.h"
|
#include "td/telegram/StickerSetId.h"
|
||||||
#include "td/telegram/StickersManager.h"
|
#include "td/telegram/StickersManager.h"
|
||||||
#include "td/telegram/Td.h"
|
#include "td/telegram/Td.h"
|
||||||
|
#include "td/telegram/WebPageId.h"
|
||||||
#include "td/telegram/WebPagesManager.h"
|
#include "td/telegram/WebPagesManager.h"
|
||||||
|
|
||||||
#include "td/utils/algorithm.h"
|
#include "td/utils/algorithm.h"
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "td/telegram/AccessRights.h"
|
#include "td/telegram/AccessRights.h"
|
||||||
#include "td/telegram/AuthManager.h"
|
#include "td/telegram/AuthManager.h"
|
||||||
#include "td/telegram/ContactsManager.h"
|
#include "td/telegram/ContactsManager.h"
|
||||||
|
#include "td/telegram/DialogAction.h"
|
||||||
#include "td/telegram/Global.h"
|
#include "td/telegram/Global.h"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
#include "td/telegram/MessagesManager.h"
|
#include "td/telegram/MessagesManager.h"
|
||||||
|
@ -4006,6 +4006,8 @@ unique_ptr<MessageContent> get_secret_message_content(
|
|||||||
FormattedText{std::move(message_text), std::move(entities)}, false,
|
FormattedText{std::move(message_text), std::move(entities)}, false,
|
||||||
&load_data_multipromise);
|
&load_data_multipromise);
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (file == nullptr && !is_media_empty) {
|
if (file == nullptr && !is_media_empty) {
|
||||||
LOG(ERROR) << "Received secret message with media, but without a file";
|
LOG(ERROR) << "Received secret message with media, but without a file";
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "td/utils/buffer.h"
|
#include "td/utils/buffer.h"
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <tuple>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
@ -850,8 +851,9 @@ class MessagesDbImpl final : public MessagesDbSyncInterface {
|
|||||||
SqliteStatement delete_scheduled_message_stmt_;
|
SqliteStatement delete_scheduled_message_stmt_;
|
||||||
SqliteStatement delete_scheduled_server_message_stmt_;
|
SqliteStatement delete_scheduled_server_message_stmt_;
|
||||||
|
|
||||||
Result<vector<MessagesDbDialogMessage>> get_messages_impl(GetMessagesStmt &stmt, DialogId dialog_id,
|
static Result<vector<MessagesDbDialogMessage>> get_messages_impl(GetMessagesStmt &stmt, DialogId dialog_id,
|
||||||
MessageId from_message_id, int32 offset, int32 limit) {
|
MessageId from_message_id, int32 offset,
|
||||||
|
int32 limit) {
|
||||||
LOG_CHECK(dialog_id.is_valid()) << dialog_id;
|
LOG_CHECK(dialog_id.is_valid()) << dialog_id;
|
||||||
CHECK(from_message_id.is_valid());
|
CHECK(from_message_id.is_valid());
|
||||||
|
|
||||||
|
@ -18167,7 +18167,7 @@ void MessagesManager::on_reorder_dialog_filters(vector<DialogFilterId> dialog_fi
|
|||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
// TODO rollback dialog_filters_ changes if error isn't 429
|
// TODO rollback dialog_filters_ changes if error isn't 429
|
||||||
} else {
|
} else {
|
||||||
if (set_dialog_filters_order(server_dialog_filters_, dialog_filter_ids)) {
|
if (set_dialog_filters_order(server_dialog_filters_, std::move(dialog_filter_ids))) {
|
||||||
save_dialog_filters();
|
save_dialog_filters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "td/telegram/MessageSearchFilter.h"
|
#include "td/telegram/MessageSearchFilter.h"
|
||||||
#include "td/telegram/MessageThreadInfo.h"
|
#include "td/telegram/MessageThreadInfo.h"
|
||||||
#include "td/telegram/MessageTtlSetting.h"
|
#include "td/telegram/MessageTtlSetting.h"
|
||||||
|
#include "td/telegram/net/DcId.h"
|
||||||
#include "td/telegram/net/NetQuery.h"
|
#include "td/telegram/net/NetQuery.h"
|
||||||
#include "td/telegram/Notification.h"
|
#include "td/telegram/Notification.h"
|
||||||
#include "td/telegram/NotificationGroupId.h"
|
#include "td/telegram/NotificationGroupId.h"
|
||||||
@ -1816,7 +1817,7 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
void on_message_media_edited(DialogId dialog_id, MessageId message_id, FileId file_id, FileId thumbnail_file_id,
|
void on_message_media_edited(DialogId dialog_id, MessageId message_id, FileId file_id, FileId thumbnail_file_id,
|
||||||
bool was_uploaded, bool was_thumbnail_uploaded, string file_reference,
|
bool was_uploaded, bool was_thumbnail_uploaded, string file_reference,
|
||||||
int32 scheduled_date, uint64 generation, Result<int32> &&result);
|
int32 schedule_date, uint64 generation, Result<int32> &&result);
|
||||||
|
|
||||||
static MessageId get_persistent_message_id(const Dialog *d, MessageId message_id);
|
static MessageId get_persistent_message_id(const Dialog *d, MessageId message_id);
|
||||||
|
|
||||||
|
@ -6643,7 +6643,7 @@ string StickersManager::get_language_emojis_database_key(const string &language_
|
|||||||
}
|
}
|
||||||
|
|
||||||
vector<string> StickersManager::search_language_emojis(const string &language_code, const string &text,
|
vector<string> StickersManager::search_language_emojis(const string &language_code, const string &text,
|
||||||
bool exact_match) const {
|
bool exact_match) {
|
||||||
LOG(INFO) << "Search for \"" << text << "\" in language " << language_code;
|
LOG(INFO) << "Search for \"" << text << "\" in language " << language_code;
|
||||||
auto key = get_language_emojis_database_key(language_code, text);
|
auto key = get_language_emojis_database_key(language_code, text);
|
||||||
if (exact_match) {
|
if (exact_match) {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "td/telegram/DialogId.h"
|
||||||
#include "td/telegram/files/FileId.h"
|
#include "td/telegram/files/FileId.h"
|
||||||
#include "td/telegram/files/FileSourceId.h"
|
#include "td/telegram/files/FileSourceId.h"
|
||||||
#include "td/telegram/FullMessageId.h"
|
#include "td/telegram/FullMessageId.h"
|
||||||
@ -658,7 +659,7 @@ class StickersManager final : public Actor {
|
|||||||
|
|
||||||
void on_get_language_codes(const string &key, Result<vector<string>> &&result);
|
void on_get_language_codes(const string &key, Result<vector<string>> &&result);
|
||||||
|
|
||||||
vector<string> search_language_emojis(const string &language_code, const string &text, bool exact_match) const;
|
static vector<string> search_language_emojis(const string &language_code, const string &text, bool exact_match);
|
||||||
|
|
||||||
void load_emoji_keywords(const string &language_code, Promise<Unit> &&promise);
|
void load_emoji_keywords(const string &language_code, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "td/telegram/StorageManager.h"
|
#include "td/telegram/StorageManager.h"
|
||||||
|
|
||||||
#include "td/telegram/ConfigShared.h"
|
#include "td/telegram/ConfigShared.h"
|
||||||
|
#include "td/telegram/DialogId.h"
|
||||||
#include "td/telegram/files/FileGcWorker.h"
|
#include "td/telegram/files/FileGcWorker.h"
|
||||||
#include "td/telegram/files/FileStatsWorker.h"
|
#include "td/telegram/files/FileStatsWorker.h"
|
||||||
#include "td/telegram/Global.h"
|
#include "td/telegram/Global.h"
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
//
|
//
|
||||||
#include "td/telegram/Td.h"
|
#include "td/telegram/Td.h"
|
||||||
|
|
||||||
#include "td/telegram/AccessRights.h"
|
|
||||||
#include "td/telegram/AnimationsManager.h"
|
#include "td/telegram/AnimationsManager.h"
|
||||||
#include "td/telegram/AudiosManager.h"
|
#include "td/telegram/AudiosManager.h"
|
||||||
#include "td/telegram/AuthManager.h"
|
#include "td/telegram/AuthManager.h"
|
||||||
@ -170,7 +169,7 @@ void Td::ResultHandler::on_result(NetQueryPtr query) {
|
|||||||
|
|
||||||
void Td::ResultHandler::send_query(NetQueryPtr query) {
|
void Td::ResultHandler::send_query(NetQueryPtr query) {
|
||||||
td->add_handler(query->id(), shared_from_this());
|
td->add_handler(query->id(), shared_from_this());
|
||||||
td->send(std::move(query));
|
send(std::move(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
class GetPromoDataQuery final : public Td::ResultHandler {
|
class GetPromoDataQuery final : public Td::ResultHandler {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/Random.h"
|
#include "td/utils/Random.h"
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
|
#include "td/utils/tl_helpers.h"
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
@ -21,15 +21,12 @@
|
|||||||
#include "td/telegram/Td.h"
|
#include "td/telegram/Td.h"
|
||||||
#include "td/telegram/TdDb.h"
|
#include "td/telegram/TdDb.h"
|
||||||
#include "td/telegram/TdParameters.h"
|
#include "td/telegram/TdParameters.h"
|
||||||
#include "td/telegram/telegram_api.h"
|
|
||||||
|
|
||||||
#include "td/utils/algorithm.h"
|
#include "td/utils/algorithm.h"
|
||||||
#include "td/utils/buffer.h"
|
#include "td/utils/buffer.h"
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/misc.h"
|
#include "td/utils/misc.h"
|
||||||
#include "td/utils/port/Clocks.h"
|
#include "td/utils/port/Clocks.h"
|
||||||
#include "td/utils/ScopeGuard.h"
|
|
||||||
#include "td/utils/Slice.h"
|
|
||||||
#include "td/utils/SliceBuilder.h"
|
#include "td/utils/SliceBuilder.h"
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
#include "td/utils/tl_helpers.h"
|
#include "td/utils/tl_helpers.h"
|
||||||
@ -124,11 +121,14 @@ class ResetTopPeerRatingQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
void on_error(uint64 id, Status status) final {
|
void on_error(uint64 id, Status status) final {
|
||||||
if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ResetTopPeerRatingQuery")) {
|
if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ResetTopPeerRatingQuery")) {
|
||||||
LOG(INFO) << "Receive error for resetTopPeerRating: " << status;
|
LOG(INFO) << "Receive error for ResetTopPeerRatingQuery: " << status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TopDialogManager::TopDialogManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
|
||||||
|
}
|
||||||
|
|
||||||
void TopDialogManager::update_is_enabled(bool is_enabled) {
|
void TopDialogManager::update_is_enabled(bool is_enabled) {
|
||||||
if (td_->auth_manager_ == nullptr || !td_->auth_manager_->is_authorized() || td_->auth_manager_->is_bot()) {
|
if (td_->auth_manager_ == nullptr || !td_->auth_manager_->is_authorized() || td_->auth_manager_->is_bot()) {
|
||||||
return;
|
return;
|
||||||
|
@ -7,12 +7,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "td/telegram/DialogId.h"
|
#include "td/telegram/DialogId.h"
|
||||||
|
#include "td/telegram/telegram_api.h"
|
||||||
#include "td/telegram/TopDialogCategory.h"
|
#include "td/telegram/TopDialogCategory.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/Status.h"
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
@ -24,8 +26,7 @@ class Td;
|
|||||||
|
|
||||||
class TopDialogManager final : public Actor {
|
class TopDialogManager final : public Actor {
|
||||||
public:
|
public:
|
||||||
TopDialogManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
|
TopDialogManager(Td *td, ActorShared<> parent);
|
||||||
}
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ class TopDialogManager final : public Actor {
|
|||||||
size_t limit;
|
size_t limit;
|
||||||
Promise<vector<DialogId>> promise;
|
Promise<vector<DialogId>> promise;
|
||||||
};
|
};
|
||||||
std::vector<GetTopDialogsQuery> pending_get_top_dialogs_;
|
vector<GetTopDialogsQuery> pending_get_top_dialogs_;
|
||||||
|
|
||||||
struct TopDialog {
|
struct TopDialog {
|
||||||
DialogId dialog_id;
|
DialogId dialog_id;
|
||||||
@ -80,7 +81,7 @@ class TopDialogManager final : public Actor {
|
|||||||
struct TopDialogs {
|
struct TopDialogs {
|
||||||
bool is_dirty = false;
|
bool is_dirty = false;
|
||||||
double rating_timestamp = 0;
|
double rating_timestamp = 0;
|
||||||
std::vector<TopDialog> dialogs;
|
vector<TopDialog> dialogs;
|
||||||
};
|
};
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
friend void store(const TopDialog &top_dialog, StorerT &storer);
|
friend void store(const TopDialog &top_dialog, StorerT &storer);
|
||||||
|
@ -1830,7 +1830,7 @@ class CliClient final : public Actor {
|
|||||||
send_request(td_api::make_object<td_api::setPassportElement>(
|
send_request(td_api::make_object<td_api::setPassportElement>(
|
||||||
as_input_passport_element(passport_element_type, arg, op == "spes"), password));
|
as_input_passport_element(passport_element_type, arg, op == "spes"), password));
|
||||||
} else if (op == "dpe") {
|
} else if (op == "dpe") {
|
||||||
string passport_element_type = std::move(args);
|
const string &passport_element_type = args;
|
||||||
send_request(td_api::make_object<td_api::deletePassportElement>(as_passport_element_type(passport_element_type)));
|
send_request(td_api::make_object<td_api::deletePassportElement>(as_passport_element_type(passport_element_type)));
|
||||||
} else if (op == "ppn") {
|
} else if (op == "ppn") {
|
||||||
send_request(td_api::make_object<td_api::processPushNotification>(args));
|
send_request(td_api::make_object<td_api::processPushNotification>(args));
|
||||||
@ -1950,7 +1950,7 @@ class CliClient final : public Actor {
|
|||||||
send_request(td_api::make_object<td_api::addContact>(
|
send_request(td_api::make_object<td_api::addContact>(
|
||||||
td_api::make_object<td_api::contact>(string(), first_name, last_name, string(), as_user_id(user_id)), false));
|
td_api::make_object<td_api::contact>(string(), first_name, last_name, string(), as_user_id(user_id)), false));
|
||||||
} else if (op == "spn") {
|
} else if (op == "spn") {
|
||||||
string user_id = std::move(args);
|
const string &user_id = args;
|
||||||
send_request(td_api::make_object<td_api::sharePhoneNumber>(as_user_id(user_id)));
|
send_request(td_api::make_object<td_api::sharePhoneNumber>(as_user_id(user_id)));
|
||||||
} else if (op == "ImportContacts" || op == "cic") {
|
} else if (op == "ImportContacts" || op == "cic") {
|
||||||
vector<string> contacts_str = full_split(args, ';');
|
vector<string> contacts_str = full_split(args, ';');
|
||||||
@ -2012,7 +2012,7 @@ class CliClient final : public Actor {
|
|||||||
offset, as_limit(limit), op == "ghl"));
|
offset, as_limit(limit), op == "ghl"));
|
||||||
}
|
}
|
||||||
} else if (op == "gcsm") {
|
} else if (op == "gcsm") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::getChatScheduledMessages>(as_chat_id(chat_id)));
|
send_request(td_api::make_object<td_api::getChatScheduledMessages>(as_chat_id(chat_id)));
|
||||||
} else if (op == "gmpf") {
|
} else if (op == "gmpf") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -2141,10 +2141,10 @@ class CliClient final : public Actor {
|
|||||||
send_request(td_api::make_object<td_api::getLanguagePackString>(language_database_path, language_pack,
|
send_request(td_api::make_object<td_api::getLanguagePackString>(language_database_path, language_pack,
|
||||||
language_code, key));
|
language_code, key));
|
||||||
} else if (op == "synclp") {
|
} else if (op == "synclp") {
|
||||||
string language_code = std::move(args);
|
const string &language_code = args;
|
||||||
send_request(td_api::make_object<td_api::synchronizeLanguagePack>(language_code));
|
send_request(td_api::make_object<td_api::synchronizeLanguagePack>(language_code));
|
||||||
} else if (op == "acslp") {
|
} else if (op == "acslp") {
|
||||||
string language_code = std::move(args);
|
const string &language_code = args;
|
||||||
send_request(td_api::make_object<td_api::addCustomServerLanguagePack>(language_code));
|
send_request(td_api::make_object<td_api::addCustomServerLanguagePack>(language_code));
|
||||||
} else if (op == "sclp") {
|
} else if (op == "sclp") {
|
||||||
string language_code;
|
string language_code;
|
||||||
@ -2438,10 +2438,10 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, chat_id, category);
|
get_args(args, chat_id, category);
|
||||||
send_request(td_api::make_object<td_api::removeTopChat>(get_top_chat_category(category), as_chat_id(chat_id)));
|
send_request(td_api::make_object<td_api::removeTopChat>(get_top_chat_category(category), as_chat_id(chat_id)));
|
||||||
} else if (op == "gsssn") {
|
} else if (op == "gsssn") {
|
||||||
string title = std::move(args);
|
const string &title = args;
|
||||||
send_request(td_api::make_object<td_api::getSuggestedStickerSetName>(title));
|
send_request(td_api::make_object<td_api::getSuggestedStickerSetName>(title));
|
||||||
} else if (op == "cssn") {
|
} else if (op == "cssn") {
|
||||||
string name = std::move(args);
|
const string &name = args;
|
||||||
send_request(td_api::make_object<td_api::checkStickerSetName>(name));
|
send_request(td_api::make_object<td_api::checkStickerSetName>(name));
|
||||||
} else if (op == "usf" || op == "usfa") {
|
} else if (op == "usf" || op == "usfa") {
|
||||||
td_api::object_ptr<td_api::InputSticker> input_sticker;
|
td_api::object_ptr<td_api::InputSticker> input_sticker;
|
||||||
@ -2551,7 +2551,7 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, chat_id, member_id);
|
get_args(args, chat_id, member_id);
|
||||||
send_request(td_api::make_object<td_api::getChatMember>(as_chat_id(chat_id), as_message_sender(member_id)));
|
send_request(td_api::make_object<td_api::getChatMember>(as_chat_id(chat_id), as_message_sender(member_id)));
|
||||||
} else if (op == "GetChatAdministrators") {
|
} else if (op == "GetChatAdministrators") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::getChatAdministrators>(as_chat_id(chat_id)));
|
send_request(td_api::make_object<td_api::getChatAdministrators>(as_chat_id(chat_id)));
|
||||||
} else if (op == "GetSupergroupAdministrators" || op == "GetSupergroupBanned" || op == "GetSupergroupBots" ||
|
} else if (op == "GetSupergroupAdministrators" || op == "GetSupergroupBanned" || op == "GetSupergroupBots" ||
|
||||||
op == "GetSupergroupContacts" || op == "GetSupergroupMembers" || op == "GetSupergroupRestricted" ||
|
op == "GetSupergroupContacts" || op == "GetSupergroupMembers" || op == "GetSupergroupRestricted" ||
|
||||||
@ -2607,7 +2607,7 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, chat_id, message_id);
|
get_args(args, chat_id, message_id);
|
||||||
send_request(td_api::make_object<td_api::getMessageViewers>(as_chat_id(chat_id), as_message_id(message_id)));
|
send_request(td_api::make_object<td_api::getMessageViewers>(as_chat_id(chat_id), as_message_id(message_id)));
|
||||||
} else if (op == "gcpm") {
|
} else if (op == "gcpm") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::getChatPinnedMessage>(as_chat_id(chat_id)));
|
send_request(td_api::make_object<td_api::getChatPinnedMessage>(as_chat_id(chat_id)));
|
||||||
} else if (op == "gms") {
|
} else if (op == "gms") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -2717,7 +2717,7 @@ class CliClient final : public Actor {
|
|||||||
} else if (op == "cuf") {
|
} else if (op == "cuf") {
|
||||||
send_request(td_api::make_object<td_api::cancelUploadFile>(as_file_id(args)));
|
send_request(td_api::make_object<td_api::cancelUploadFile>(as_file_id(args)));
|
||||||
} else if (op == "delf" || op == "DeleteFile") {
|
} else if (op == "delf" || op == "DeleteFile") {
|
||||||
string file_id = std::move(args);
|
const string &file_id = args;
|
||||||
send_request(td_api::make_object<td_api::deleteFile>(as_file_id(file_id)));
|
send_request(td_api::make_object<td_api::deleteFile>(as_file_id(file_id)));
|
||||||
} else if (op == "dm" || op == "dmr") {
|
} else if (op == "dm" || op == "dmr") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -2847,7 +2847,7 @@ class CliClient final : public Actor {
|
|||||||
send_request(td_api::make_object<td_api::toggleGroupCallScreenSharingIsPaused>(as_group_call_id(group_call_id),
|
send_request(td_api::make_object<td_api::toggleGroupCallScreenSharingIsPaused>(as_group_call_id(group_call_id),
|
||||||
is_paused));
|
is_paused));
|
||||||
} else if (op == "egcss") {
|
} else if (op == "egcss") {
|
||||||
string group_call_id = std::move(args);
|
const string &group_call_id = args;
|
||||||
send_request(td_api::make_object<td_api::endGroupCallScreenSharing>(as_group_call_id(group_call_id)));
|
send_request(td_api::make_object<td_api::endGroupCallScreenSharing>(as_group_call_id(group_call_id)));
|
||||||
} else if (op == "sgct") {
|
} else if (op == "sgct") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -2899,7 +2899,7 @@ class CliClient final : public Actor {
|
|||||||
send_request(td_api::make_object<td_api::startGroupCallRecording>(as_group_call_id(chat_id), title, record_video,
|
send_request(td_api::make_object<td_api::startGroupCallRecording>(as_group_call_id(chat_id), title, record_video,
|
||||||
use_portrait_orientation));
|
use_portrait_orientation));
|
||||||
} else if (op == "egcr") {
|
} else if (op == "egcr") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::endGroupCallRecording>(as_group_call_id(chat_id)));
|
send_request(td_api::make_object<td_api::endGroupCallRecording>(as_group_call_id(chat_id)));
|
||||||
} else if (op == "tgcpim") {
|
} else if (op == "tgcpim") {
|
||||||
string group_call_id;
|
string group_call_id;
|
||||||
@ -2933,7 +2933,7 @@ class CliClient final : public Actor {
|
|||||||
} else if (op == "dgc") {
|
} else if (op == "dgc") {
|
||||||
send_request(td_api::make_object<td_api::discardGroupCall>(as_group_call_id(args)));
|
send_request(td_api::make_object<td_api::discardGroupCall>(as_group_call_id(args)));
|
||||||
} else if (op == "rpcil") {
|
} else if (op == "rpcil") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::replacePrimaryChatInviteLink>(as_chat_id(chat_id)));
|
send_request(td_api::make_object<td_api::replacePrimaryChatInviteLink>(as_chat_id(chat_id)));
|
||||||
} else if (op == "ccilt") {
|
} else if (op == "ccilt") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -2955,7 +2955,7 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, chat_id, invite_link);
|
get_args(args, chat_id, invite_link);
|
||||||
send_request(td_api::make_object<td_api::revokeChatInviteLink>(as_chat_id(chat_id), invite_link));
|
send_request(td_api::make_object<td_api::revokeChatInviteLink>(as_chat_id(chat_id), invite_link));
|
||||||
} else if (op == "gcilc") {
|
} else if (op == "gcilc") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::getChatInviteLinkCounts>(as_chat_id(chat_id)));
|
send_request(td_api::make_object<td_api::getChatInviteLinkCounts>(as_chat_id(chat_id)));
|
||||||
} else if (op == "gcil") {
|
} else if (op == "gcil") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -3731,10 +3731,10 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, supergroup_id, force);
|
get_args(args, supergroup_id, force);
|
||||||
send_request(td_api::make_object<td_api::createSupergroupChat>(as_supergroup_id(supergroup_id), force));
|
send_request(td_api::make_object<td_api::createSupergroupChat>(as_supergroup_id(supergroup_id), force));
|
||||||
} else if (op == "gcltac") {
|
} else if (op == "gcltac") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::getChatListsToAddChat>(as_chat_id(chat_id)));
|
send_request(td_api::make_object<td_api::getChatListsToAddChat>(as_chat_id(chat_id)));
|
||||||
} else if (op == "actl" || op == "actla" || begins_with(op, "actl-")) {
|
} else if (op == "actl" || op == "actla" || begins_with(op, "actl-")) {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::addChatToList>(as_chat_id(chat_id), as_chat_list(op)));
|
send_request(td_api::make_object<td_api::addChatToList>(as_chat_id(chat_id), as_chat_list(op)));
|
||||||
} else if (op == "gcf") {
|
} else if (op == "gcf") {
|
||||||
send_request(td_api::make_object<td_api::getChatFilter>(as_chat_filter_id(args)));
|
send_request(td_api::make_object<td_api::getChatFilter>(as_chat_filter_id(args)));
|
||||||
@ -3765,7 +3765,7 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, chat_id, title);
|
get_args(args, chat_id, title);
|
||||||
send_request(td_api::make_object<td_api::setChatTitle>(as_chat_id(chat_id), title));
|
send_request(td_api::make_object<td_api::setChatTitle>(as_chat_id(chat_id), title));
|
||||||
} else if (op == "scpe") {
|
} else if (op == "scpe") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::setChatPhoto>(as_chat_id(chat_id), nullptr));
|
send_request(td_api::make_object<td_api::setChatPhoto>(as_chat_id(chat_id), nullptr));
|
||||||
} else if (op == "scpp") {
|
} else if (op == "scpp") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -4030,7 +4030,7 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, chat_id, message_id);
|
get_args(args, chat_id, message_id);
|
||||||
send_request(td_api::make_object<td_api::unpinChatMessage>(as_chat_id(chat_id), as_message_id(message_id)));
|
send_request(td_api::make_object<td_api::unpinChatMessage>(as_chat_id(chat_id), as_message_id(message_id)));
|
||||||
} else if (op == "uacm") {
|
} else if (op == "uacm") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::unpinAllChatMessages>(as_chat_id(chat_id)));
|
send_request(td_api::make_object<td_api::unpinAllChatMessages>(as_chat_id(chat_id)));
|
||||||
} else if (op == "grib") {
|
} else if (op == "grib") {
|
||||||
send_request(td_api::make_object<td_api::getRecentInlineBots>());
|
send_request(td_api::make_object<td_api::getRecentInlineBots>());
|
||||||
@ -4088,10 +4088,10 @@ class CliClient final : public Actor {
|
|||||||
send_request(td_api::make_object<td_api::setProfilePhoto>(td_api::make_object<td_api::inputChatPhotoAnimation>(
|
send_request(td_api::make_object<td_api::setProfilePhoto>(td_api::make_object<td_api::inputChatPhotoAnimation>(
|
||||||
as_input_file(animation), to_double(main_frame_timestamp))));
|
as_input_file(animation), to_double(main_frame_timestamp))));
|
||||||
} else if (op == "sh") {
|
} else if (op == "sh") {
|
||||||
auto prefix = std::move(args);
|
const string &prefix = args;
|
||||||
send_request(td_api::make_object<td_api::searchHashtags>(prefix, 10));
|
send_request(td_api::make_object<td_api::searchHashtags>(prefix, 10));
|
||||||
} else if (op == "rrh") {
|
} else if (op == "rrh") {
|
||||||
auto hashtag = std::move(args);
|
const string &hashtag = args;
|
||||||
send_request(td_api::make_object<td_api::removeRecentHashtag>(hashtag));
|
send_request(td_api::make_object<td_api::removeRecentHashtag>(hashtag));
|
||||||
} else if (op == "view" || op == "viewt") {
|
} else if (op == "view" || op == "viewt") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -4115,16 +4115,16 @@ class CliClient final : public Actor {
|
|||||||
send_request(
|
send_request(
|
||||||
td_api::make_object<td_api::clickAnimatedEmojiMessage>(as_chat_id(chat_id), as_message_id(message_id)));
|
td_api::make_object<td_api::clickAnimatedEmojiMessage>(as_chat_id(chat_id), as_message_id(message_id)));
|
||||||
} else if (op == "gilt") {
|
} else if (op == "gilt") {
|
||||||
string link = std::move(args);
|
const string &link = args;
|
||||||
send_request(td_api::make_object<td_api::getInternalLinkType>(link));
|
send_request(td_api::make_object<td_api::getInternalLinkType>(link));
|
||||||
} else if (op == "geli") {
|
} else if (op == "geli") {
|
||||||
string link = std::move(args);
|
const string &link = args;
|
||||||
send_request(td_api::make_object<td_api::getExternalLinkInfo>(link));
|
send_request(td_api::make_object<td_api::getExternalLinkInfo>(link));
|
||||||
} else if (op == "gel" || op == "gelw") {
|
} else if (op == "gel" || op == "gelw") {
|
||||||
string link = std::move(args);
|
const string &link = args;
|
||||||
send_request(td_api::make_object<td_api::getExternalLink>(link, op == "gelw"));
|
send_request(td_api::make_object<td_api::getExternalLink>(link, op == "gelw"));
|
||||||
} else if (op == "racm") {
|
} else if (op == "racm") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::readAllChatMentions>(as_chat_id(chat_id)));
|
send_request(td_api::make_object<td_api::readAllChatMentions>(as_chat_id(chat_id)));
|
||||||
} else if (op == "tre") {
|
} else if (op == "tre") {
|
||||||
send_request(td_api::make_object<td_api::testReturnError>(
|
send_request(td_api::make_object<td_api::testReturnError>(
|
||||||
@ -4175,7 +4175,7 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, group_id, max_notification_id);
|
get_args(args, group_id, max_notification_id);
|
||||||
send_request(td_api::make_object<td_api::removeNotificationGroup>(group_id, max_notification_id));
|
send_request(td_api::make_object<td_api::removeNotificationGroup>(group_id, max_notification_id));
|
||||||
} else if (op == "rcab") {
|
} else if (op == "rcab") {
|
||||||
string chat_id = std::move(args);
|
const string &chat_id = args;
|
||||||
send_request(td_api::make_object<td_api::removeChatActionBar>(as_chat_id(chat_id)));
|
send_request(td_api::make_object<td_api::removeChatActionBar>(as_chat_id(chat_id)));
|
||||||
} else if (op == "rc") {
|
} else if (op == "rc") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -4354,7 +4354,7 @@ class CliClient final : public Actor {
|
|||||||
execute(std::move(request));
|
execute(std::move(request));
|
||||||
}
|
}
|
||||||
} else if (op == "gltvl" || op == "gltvle" || op == "gtag") {
|
} else if (op == "gltvl" || op == "gltvle" || op == "gtag") {
|
||||||
string tag = std::move(args);
|
const string &tag = args;
|
||||||
auto request = td_api::make_object<td_api::getLogTagVerbosityLevel>(tag);
|
auto request = td_api::make_object<td_api::getLogTagVerbosityLevel>(tag);
|
||||||
if (op == "gltvl") {
|
if (op == "gltvl") {
|
||||||
send_request(std::move(request));
|
send_request(std::move(request));
|
||||||
|
@ -139,7 +139,7 @@ class FileDb final : public FileDbInterface {
|
|||||||
pmc.commit_transaction().ensure();
|
pmc.commit_transaction().ensure();
|
||||||
}
|
}
|
||||||
|
|
||||||
void optimize_refs(const std::vector<FileDbId> ids, FileDbId main_id) {
|
void optimize_refs(std::vector<FileDbId> ids, FileDbId main_id) {
|
||||||
LOG(INFO) << "Optimize " << ids.size() << " ids in file database to " << main_id.get();
|
LOG(INFO) << "Optimize " << ids.size() << " ids in file database to " << main_id.get();
|
||||||
auto &pmc = file_pmc();
|
auto &pmc = file_pmc();
|
||||||
pmc.begin_write_transaction().ensure();
|
pmc.begin_write_transaction().ensure();
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "td/utils/misc.h"
|
#include "td/utils/misc.h"
|
||||||
#include "td/utils/port/Clocks.h"
|
#include "td/utils/port/Clocks.h"
|
||||||
#include "td/utils/port/path.h"
|
#include "td/utils/port/path.h"
|
||||||
#include "td/utils/Status.h"
|
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "td/utils/port/Stat.h"
|
#include "td/utils/port/Stat.h"
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/SliceBuilder.h"
|
#include "td/utils/SliceBuilder.h"
|
||||||
#include "td/utils/Status.h"
|
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
#include "td/utils/tl_parsers.h"
|
#include "td/utils/tl_parsers.h"
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/Slice.h"
|
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
@ -132,12 +132,13 @@ class NetStatsManager final : public Actor {
|
|||||||
f(call_net_stats_, CALL_NET_STATS_ID, CSlice("calls"), FileType::None);
|
f(call_net_stats_, CALL_NET_STATS_ID, CSlice("calls"), FileType::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_network_stats_impl(NetStatsInfo &info, const NetworkStatsEntry &entry);
|
static void add_network_stats_impl(NetStatsInfo &info, const NetworkStatsEntry &entry);
|
||||||
|
|
||||||
void start_up() final;
|
void start_up() final;
|
||||||
void update(NetStatsInfo &info, bool force_save);
|
|
||||||
|
static void update(NetStatsInfo &info, bool force_save);
|
||||||
static void save_stats(NetStatsInfo &info, NetType net_type);
|
static void save_stats(NetStatsInfo &info, NetType net_type);
|
||||||
void info_loop(NetStatsInfo &info);
|
static void info_loop(NetStatsInfo &info);
|
||||||
|
|
||||||
void on_stats_updated(size_t id);
|
void on_stats_updated(size_t id);
|
||||||
void on_net_type_updated(NetType net_type);
|
void on_net_type_updated(NetType net_type);
|
||||||
|
@ -34,7 +34,7 @@ EMSCRIPTEN_KEEPALIVE double td_emscripten_get_timeout() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main() {
|
||||||
emscripten_exit_with_live_runtime();
|
emscripten_exit_with_live_runtime();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class MainActor final : public td::Actor {
|
|||||||
td::ActorOwn<Worker> worker_;
|
td::ActorOwn<Worker> worker_;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(void) {
|
int main() {
|
||||||
td::ConcurrentScheduler scheduler;
|
td::ConcurrentScheduler scheduler;
|
||||||
scheduler.init(4 /*threads_count*/);
|
scheduler.init(4 /*threads_count*/);
|
||||||
scheduler.start();
|
scheduler.start();
|
||||||
|
@ -407,10 +407,10 @@ class CancellablePromise final : public PromiseT {
|
|||||||
CancellablePromise(CancellationToken cancellation_token, ArgsT &&... args)
|
CancellablePromise(CancellationToken cancellation_token, ArgsT &&... args)
|
||||||
: PromiseT(std::forward<ArgsT>(args)...), cancellation_token_(std::move(cancellation_token)) {
|
: PromiseT(std::forward<ArgsT>(args)...), cancellation_token_(std::move(cancellation_token)) {
|
||||||
}
|
}
|
||||||
virtual bool is_cancellable() const {
|
bool is_cancellable() const final {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual bool is_canceled() const {
|
bool is_canceled() const final {
|
||||||
return static_cast<bool>(cancellation_token_);
|
return static_cast<bool>(cancellation_token_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,9 +50,9 @@ TEST(MultiTimeout, bug) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TimeoutManager final : public td::Actor {
|
class TimeoutManager final : public td::Actor {
|
||||||
public:
|
|
||||||
static td::int32 count;
|
static td::int32 count;
|
||||||
|
|
||||||
|
public:
|
||||||
TimeoutManager() {
|
TimeoutManager() {
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
template <class ContainerT>
|
template <class ContainerT>
|
||||||
static typename ContainerT::value_type &rand_elem(ContainerT &cont) {
|
static typename ContainerT::value_type &rand_elem(ContainerT &cont) {
|
||||||
CHECK(0 < cont.size() && cont.size() <= static_cast<size_t>(std::numeric_limits<int>::max()));
|
CHECK(0 < cont.size() && cont.size() <= static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||||
@ -338,7 +336,6 @@ class SimpleActor final : public td::Actor {
|
|||||||
td::uint32 q_ = 1;
|
td::uint32 q_ = 1;
|
||||||
td::uint32 p_ = 0;
|
td::uint32 p_ = 0;
|
||||||
};
|
};
|
||||||
} // namespace
|
|
||||||
|
|
||||||
class SendToDead final : public td::Actor {
|
class SendToDead final : public td::Actor {
|
||||||
public:
|
public:
|
||||||
@ -470,7 +467,7 @@ class XContext final : public td::ActorContext {
|
|||||||
void validate() {
|
void validate() {
|
||||||
CHECK(x == 1234);
|
CHECK(x == 1234);
|
||||||
}
|
}
|
||||||
~XContext() {
|
~XContext() final {
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
int x = 1234;
|
int x = 1234;
|
||||||
|
@ -9,13 +9,11 @@
|
|||||||
#include "td/actor/MultiPromise.h"
|
#include "td/actor/MultiPromise.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
#include "td/actor/SleepActor.h"
|
#include "td/actor/SleepActor.h"
|
||||||
#include "td/actor/Timeout.h"
|
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/MpscPollableQueue.h"
|
#include "td/utils/MpscPollableQueue.h"
|
||||||
#include "td/utils/Observer.h"
|
#include "td/utils/Observer.h"
|
||||||
#include "td/utils/port/detail/PollableFd.h"
|
|
||||||
#include "td/utils/port/FileFd.h"
|
#include "td/utils/port/FileFd.h"
|
||||||
#include "td/utils/port/thread.h"
|
#include "td/utils/port/thread.h"
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
@ -27,8 +25,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
static const size_t BUF_SIZE = 1024 * 1024;
|
static const size_t BUF_SIZE = 1024 * 1024;
|
||||||
static char buf[BUF_SIZE];
|
static char buf[BUF_SIZE];
|
||||||
static char buf2[BUF_SIZE];
|
static char buf2[BUF_SIZE];
|
||||||
@ -199,7 +195,6 @@ class PrintChar final : public td::Actor {
|
|||||||
char char_;
|
char char_;
|
||||||
int cnt_;
|
int cnt_;
|
||||||
};
|
};
|
||||||
} // namespace
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Yield must add actor to the end of queue
|
// Yield must add actor to the end of queue
|
||||||
@ -315,7 +310,6 @@ TEST(Actors, open_close) {
|
|||||||
scheduler.finish();
|
scheduler.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
class MsgActor : public td::Actor {
|
class MsgActor : public td::Actor {
|
||||||
public:
|
public:
|
||||||
virtual void msg() = 0;
|
virtual void msg() = 0;
|
||||||
@ -353,7 +347,6 @@ class MasterActor final : public MsgActor {
|
|||||||
}
|
}
|
||||||
td::uint64 alive_ = 123456789;
|
td::uint64 alive_ = 123456789;
|
||||||
};
|
};
|
||||||
} // namespace
|
|
||||||
|
|
||||||
TEST(Actors, call_after_destruct) {
|
TEST(Actors, call_after_destruct) {
|
||||||
td::Scheduler scheduler;
|
td::Scheduler scheduler;
|
||||||
@ -655,9 +648,9 @@ TEST(Actors, send_from_other_threads) {
|
|||||||
|
|
||||||
class DelayedCall final : public td::Actor {
|
class DelayedCall final : public td::Actor {
|
||||||
public:
|
public:
|
||||||
void on_called(int *order) {
|
void on_called(int *step) {
|
||||||
CHECK(*order == 0);
|
CHECK(*step == 0);
|
||||||
*order = 1;
|
*step = 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -666,21 +659,21 @@ class MultiPromiseSendClosureLaterTest final : public td::Actor {
|
|||||||
void start_up() final {
|
void start_up() final {
|
||||||
delayed_call_ = td::create_actor<DelayedCall>("DelayedCall").release();
|
delayed_call_ = td::create_actor<DelayedCall>("DelayedCall").release();
|
||||||
mpa_.add_promise(td::PromiseCreator::lambda([this](td::Unit) {
|
mpa_.add_promise(td::PromiseCreator::lambda([this](td::Unit) {
|
||||||
CHECK(order_ == 1);
|
CHECK(step_ == 1);
|
||||||
order_++;
|
step_++;
|
||||||
td::Scheduler::instance()->finish();
|
td::Scheduler::instance()->finish();
|
||||||
}));
|
}));
|
||||||
auto lock = mpa_.get_promise();
|
auto lock = mpa_.get_promise();
|
||||||
td::send_closure_later(delayed_call_, &DelayedCall::on_called, &order_);
|
td::send_closure_later(delayed_call_, &DelayedCall::on_called, &step_);
|
||||||
lock.set_value(td::Unit());
|
lock.set_value(td::Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tear_down() final {
|
void tear_down() final {
|
||||||
CHECK(order_ == 2);
|
CHECK(step_ == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int order_ = 0;
|
int step_ = 0;
|
||||||
td::MultiPromiseActor mpa_{"MultiPromiseActor"};
|
td::MultiPromiseActor mpa_{"MultiPromiseActor"};
|
||||||
td::ActorId<DelayedCall> delayed_call_;
|
td::ActorId<DelayedCall> delayed_call_;
|
||||||
};
|
};
|
||||||
|
@ -7,11 +7,10 @@
|
|||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
#include "td/actor/ConcurrentScheduler.h"
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/SliceBuilder.h"
|
#include "td/utils/SliceBuilder.h"
|
||||||
#include "td/utils/tests.h"
|
#include "td/utils/tests.h"
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
class PowerWorker final : public td::Actor {
|
class PowerWorker final : public td::Actor {
|
||||||
public:
|
public:
|
||||||
class Callback {
|
class Callback {
|
||||||
@ -125,7 +124,6 @@ static void test_workers(int threads_n, int workers_n, int queries_n, int query_
|
|||||||
|
|
||||||
// sched.test_one_thread_run();
|
// sched.test_one_thread_run();
|
||||||
}
|
}
|
||||||
} // namespace
|
|
||||||
|
|
||||||
TEST(Actors, workers_big_query_one_thread) {
|
TEST(Actors, workers_big_query_one_thread) {
|
||||||
test_workers(0, 10, 1000, 300000);
|
test_workers(0, 10, 1000, 300000);
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/format.h"
|
#include "td/utils/format.h"
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/port/Stat.h"
|
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@ class TQueue {
|
|||||||
|
|
||||||
struct Event {
|
struct Event {
|
||||||
EventId id;
|
EventId id;
|
||||||
|
int32 expires_at{0};
|
||||||
Slice data;
|
Slice data;
|
||||||
int64 extra{0};
|
int64 extra{0};
|
||||||
int32 expires_at{0};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RawEvent {
|
struct RawEvent {
|
||||||
|
@ -25,7 +25,7 @@ class MpmcEagerWaiter {
|
|||||||
int yields;
|
int yields;
|
||||||
uint32 worker_id;
|
uint32 worker_id;
|
||||||
};
|
};
|
||||||
void init_slot(Slot &slot, uint32 worker_id) {
|
static void init_slot(Slot &slot, uint32 worker_id) {
|
||||||
slot.yields = 0;
|
slot.yields = 0;
|
||||||
slot.worker_id = worker_id;
|
slot.worker_id = worker_id;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,6 @@ class MpmcEagerWaiter {
|
|||||||
if (slot.yields < RoundsTillSleepy) {
|
if (slot.yields < RoundsTillSleepy) {
|
||||||
td::this_thread::yield();
|
td::this_thread::yield();
|
||||||
slot.yields++;
|
slot.yields++;
|
||||||
return;
|
|
||||||
} else if (slot.yields == RoundsTillSleepy) {
|
} else if (slot.yields == RoundsTillSleepy) {
|
||||||
auto state = state_.load(std::memory_order_relaxed);
|
auto state = state_.load(std::memory_order_relaxed);
|
||||||
if (!State::has_worker(state)) {
|
if (!State::has_worker(state)) {
|
||||||
@ -50,7 +49,6 @@ class MpmcEagerWaiter {
|
|||||||
}
|
}
|
||||||
td::this_thread::yield();
|
td::this_thread::yield();
|
||||||
slot.yields = 0;
|
slot.yields = 0;
|
||||||
return;
|
|
||||||
} else if (slot.yields < RoundsTillAsleep) {
|
} else if (slot.yields < RoundsTillAsleep) {
|
||||||
auto state = state_.load(std::memory_order_acquire);
|
auto state = state_.load(std::memory_order_acquire);
|
||||||
if (State::still_sleepy(state, slot.worker_id)) {
|
if (State::still_sleepy(state, slot.worker_id)) {
|
||||||
@ -59,7 +57,6 @@ class MpmcEagerWaiter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
slot.yields = 0;
|
slot.yields = 0;
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
auto state = state_.load(std::memory_order_acquire);
|
auto state = state_.load(std::memory_order_acquire);
|
||||||
if (State::still_sleepy(state, slot.worker_id)) {
|
if (State::still_sleepy(state, slot.worker_id)) {
|
||||||
@ -69,7 +66,6 @@ class MpmcEagerWaiter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
slot.yields = 0;
|
slot.yields = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +74,6 @@ class MpmcEagerWaiter {
|
|||||||
notify_cold();
|
notify_cold();
|
||||||
}
|
}
|
||||||
slot.yields = 0;
|
slot.yields = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void close() {
|
void close() {
|
||||||
@ -195,7 +190,7 @@ class MpmcSleepyWaiter {
|
|||||||
// If possible - in Search state
|
// If possible - in Search state
|
||||||
//
|
//
|
||||||
|
|
||||||
void init_slot(Slot &slot, int32 worker_id) {
|
static void init_slot(Slot &slot, int32 worker_id) {
|
||||||
slot.state_ = Slot::State::Work;
|
slot.state_ = Slot::State::Work;
|
||||||
slot.unpark_flag_ = false;
|
slot.unpark_flag_ = false;
|
||||||
slot.worker_id = worker_id;
|
slot.worker_id = worker_id;
|
||||||
|
@ -26,7 +26,7 @@ class EventFdLinux final : public EventFdBase {
|
|||||||
EventFdLinux();
|
EventFdLinux();
|
||||||
EventFdLinux(EventFdLinux &&) noexcept;
|
EventFdLinux(EventFdLinux &&) noexcept;
|
||||||
EventFdLinux &operator=(EventFdLinux &&) noexcept;
|
EventFdLinux &operator=(EventFdLinux &&) noexcept;
|
||||||
~EventFdLinux() override;
|
~EventFdLinux() final;
|
||||||
|
|
||||||
void init() final;
|
void init() final;
|
||||||
|
|
||||||
|
@ -128,12 +128,14 @@ class uint128_emulated {
|
|||||||
*mod_res = from;
|
*mod_res = from;
|
||||||
}
|
}
|
||||||
uint128 div(uint128 other) const {
|
uint128 div(uint128 other) const {
|
||||||
uint128 a, b;
|
uint128 a;
|
||||||
|
uint128 b;
|
||||||
divmod(other, &a, &b);
|
divmod(other, &a, &b);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
uint128 mod(uint128 other) const {
|
uint128 mod(uint128 other) const {
|
||||||
uint128 a, b;
|
uint128 a;
|
||||||
|
uint128 b;
|
||||||
divmod(other, &a, &b);
|
divmod(other, &a, &b);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
@ -151,7 +153,8 @@ class uint128_emulated {
|
|||||||
uy = uy.negate();
|
uy = uy.negate();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint128 t_quot, t_mod;
|
uint128 t_quot;
|
||||||
|
uint128 t_mod;
|
||||||
x.divmod(uy, &t_quot, &t_mod);
|
x.divmod(uy, &t_quot, &t_mod);
|
||||||
*quot = t_quot.lo();
|
*quot = t_quot.lo();
|
||||||
*rem = t_mod.lo();
|
*rem = t_mod.lo();
|
||||||
@ -266,8 +269,8 @@ class uint128_intrinsic {
|
|||||||
}
|
}
|
||||||
void divmod_signed(int64 y, int64 *quot, int64 *rem) const {
|
void divmod_signed(int64 y, int64 *quot, int64 *rem) const {
|
||||||
CHECK(y != 0);
|
CHECK(y != 0);
|
||||||
*quot = (int64)(signed_value() / y);
|
*quot = static_cast<int64>(signed_value() / y);
|
||||||
*rem = (int64)(signed_value() % y);
|
*rem = static_cast<int64>(signed_value() % y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -42,7 +42,7 @@ TEST(EpochBaseMemoryReclamation, stress) {
|
|||||||
locker.retire();
|
locker.retire();
|
||||||
}
|
}
|
||||||
if (td::Random::fast(0, 5) == 0) {
|
if (td::Random::fast(0, 5) == 0) {
|
||||||
std::string *new_str = new std::string(td::Random::fast_bool() ? "one" : "twotwo");
|
auto *new_str = new td::string(td::Random::fast_bool() ? "one" : "twotwo");
|
||||||
if (node.name_.compare_exchange_strong(str, new_str, std::memory_order_acq_rel)) {
|
if (node.name_.compare_exchange_strong(str, new_str, std::memory_order_acq_rel)) {
|
||||||
locker.retire(str);
|
locker.retire(str);
|
||||||
} else {
|
} else {
|
||||||
|
@ -36,7 +36,7 @@ TEST(HazardPointers, stress) {
|
|||||||
}
|
}
|
||||||
holder.clear();
|
holder.clear();
|
||||||
if (td::Random::fast(0, 5) == 0) {
|
if (td::Random::fast(0, 5) == 0) {
|
||||||
std::string *new_str = new std::string(td::Random::fast_bool() ? "one" : "twotwo");
|
auto *new_str = new td::string(td::Random::fast_bool() ? "one" : "twotwo");
|
||||||
if (node.name_.compare_exchange_strong(str, new_str, std::memory_order_acq_rel)) {
|
if (node.name_.compare_exchange_strong(str, new_str, std::memory_order_acq_rel)) {
|
||||||
hazard_pointers.retire(thread_id, str);
|
hazard_pointers.retire(thread_id, str);
|
||||||
} else {
|
} else {
|
||||||
|
@ -110,7 +110,8 @@ static void do_run_list_test(ListRootT &root, std::atomic<td::uint64> &id) {
|
|||||||
nodes[i] = std::move(nodes[j]);
|
nodes[i] = std::move(nodes[j]);
|
||||||
};
|
};
|
||||||
auto validate = [&] {
|
auto validate = [&] {
|
||||||
std::multiset<td::uint64> in_list, not_in_list;
|
std::multiset<td::uint64> in_list;
|
||||||
|
std::multiset<td::uint64> not_in_list;
|
||||||
for (auto &node : nodes) {
|
for (auto &node : nodes) {
|
||||||
if (get_data(node).in_list.get()) {
|
if (get_data(node).in_list.get()) {
|
||||||
in_list.insert(get_data(node).value.get());
|
in_list.insert(get_data(node).value.get());
|
||||||
|
@ -50,7 +50,7 @@ TEST(OneValue, stress) {
|
|||||||
std::vector<td::thread> threads;
|
std::vector<td::thread> threads;
|
||||||
td::OneValue<std::string> value;
|
td::OneValue<std::string> value;
|
||||||
for (size_t i = 0; i < 2; i++) {
|
for (size_t i = 0; i < 2; i++) {
|
||||||
threads.push_back(td::thread([&, id = i] {
|
threads.emplace_back([&, id = i] {
|
||||||
for (td::uint64 round = 1; round < 100000; round++) {
|
for (td::uint64 round = 1; round < 100000; round++) {
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
value.reset();
|
value.reset();
|
||||||
@ -77,7 +77,7 @@ TEST(OneValue, stress) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
for (auto &thread : threads) {
|
for (auto &thread : threads) {
|
||||||
thread.join();
|
thread.join();
|
||||||
|
@ -39,7 +39,7 @@ static void test_waiter_stress_one_one() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
typename W::Slot slot;
|
typename W::Slot slot;
|
||||||
waiter->init_slot(slot, id);
|
W::init_slot(slot, id);
|
||||||
for (size_t i = 1; i <= write_cnt; i++) {
|
for (size_t i = 1; i <= write_cnt; i++) {
|
||||||
while (true) {
|
while (true) {
|
||||||
auto x = value.load(std::memory_order_relaxed);
|
auto x = value.load(std::memory_order_relaxed);
|
||||||
@ -106,7 +106,7 @@ static void test_waiter_stress() {
|
|||||||
}
|
}
|
||||||
} else if (id > 10 && id - 10 <= read_n) {
|
} else if (id > 10 && id - 10 <= read_n) {
|
||||||
typename W::Slot slot;
|
typename W::Slot slot;
|
||||||
waiter->init_slot(slot, id);
|
W::init_slot(slot, id);
|
||||||
while (true) {
|
while (true) {
|
||||||
auto x = read_pos.load(std::memory_order_relaxed);
|
auto x = read_pos.load(std::memory_order_relaxed);
|
||||||
if (x == end_pos) {
|
if (x == end_pos) {
|
||||||
|
@ -17,7 +17,7 @@ TEST(OptionParser, run) {
|
|||||||
td::string exename = "exename";
|
td::string exename = "exename";
|
||||||
td::vector<td::string> args;
|
td::vector<td::string> args;
|
||||||
auto run_option_parser = [&](td::string command_line) {
|
auto run_option_parser = [&](td::string command_line) {
|
||||||
args = td::full_split(command_line, ' ');
|
args = td::full_split(std::move(command_line), ' ');
|
||||||
td::vector<char *> argv;
|
td::vector<char *> argv;
|
||||||
argv.push_back(&exename[0]);
|
argv.push_back(&exename[0]);
|
||||||
for (auto &arg : args) {
|
for (auto &arg : args) {
|
||||||
@ -29,10 +29,11 @@ TEST(OptionParser, run) {
|
|||||||
td::uint64 chosen_options = 0;
|
td::uint64 chosen_options = 0;
|
||||||
td::vector<td::string> chosen_parameters;
|
td::vector<td::string> chosen_parameters;
|
||||||
auto test_success = [&](td::string command_line, td::uint64 expected_options,
|
auto test_success = [&](td::string command_line, td::uint64 expected_options,
|
||||||
td::vector<td::string> expected_parameters, td::vector<td::string> expected_result) {
|
const td::vector<td::string> &expected_parameters,
|
||||||
|
const td::vector<td::string> &expected_result) {
|
||||||
chosen_options = 0;
|
chosen_options = 0;
|
||||||
chosen_parameters.clear();
|
chosen_parameters.clear();
|
||||||
auto result = run_option_parser(command_line);
|
auto result = run_option_parser(std::move(command_line));
|
||||||
ASSERT_TRUE(result.is_ok());
|
ASSERT_TRUE(result.is_ok());
|
||||||
ASSERT_EQ(expected_options, chosen_options);
|
ASSERT_EQ(expected_options, chosen_options);
|
||||||
ASSERT_EQ(expected_parameters, chosen_parameters);
|
ASSERT_EQ(expected_parameters, chosen_parameters);
|
||||||
@ -42,7 +43,7 @@ TEST(OptionParser, run) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto test_fail = [&](td::string command_line) {
|
auto test_fail = [&](td::string command_line) {
|
||||||
auto result = run_option_parser(command_line);
|
auto result = run_option_parser(std::move(command_line));
|
||||||
ASSERT_TRUE(result.is_error());
|
ASSERT_TRUE(result.is_error());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ TEST(OrderedEventsProcessor, random) {
|
|||||||
std::vector<std::pair<int, int>> v;
|
std::vector<std::pair<int, int>> v;
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
auto shift = td::Random::fast_bool() ? td::Random::fast(0, d) : td::Random::fast(0, 1) * d;
|
auto shift = td::Random::fast_bool() ? td::Random::fast(0, d) : td::Random::fast(0, 1) * d;
|
||||||
v.push_back({i + shift, i + offset});
|
v.emplace_back(i + shift, i + offset);
|
||||||
}
|
}
|
||||||
std::sort(v.begin(), v.end());
|
std::sort(v.begin(), v.end());
|
||||||
|
|
||||||
|
@ -61,7 +61,8 @@ TEST(SharedSlice, Hands) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
td::Stage stage;
|
td::Stage stage;
|
||||||
td::SharedSlice a, b;
|
td::SharedSlice a;
|
||||||
|
td::SharedSlice b;
|
||||||
td::vector<td::thread> threads(2);
|
td::vector<td::thread> threads(2);
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
threads[i] = td::thread([i, &stage, &a, &b] {
|
threads[i] = td::thread([i, &stage, &a, &b] {
|
||||||
|
@ -72,7 +72,7 @@ TEST(Crypto, AesCtrState) {
|
|||||||
state.init(as_slice(key), as_slice(iv));
|
state.init(as_slice(key), as_slice(iv));
|
||||||
td::string t(length, '\0');
|
td::string t(length, '\0');
|
||||||
std::size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
for (auto str : td::rand_split(td::string(length, '\0'))) {
|
for (const auto &str : td::rand_split(td::string(length, '\0'))) {
|
||||||
auto len = str.size();
|
auto len = str.size();
|
||||||
state.encrypt(td::Slice(s).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
state.encrypt(td::Slice(s).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
||||||
pos += len;
|
pos += len;
|
||||||
@ -80,7 +80,7 @@ TEST(Crypto, AesCtrState) {
|
|||||||
ASSERT_EQ(answers1[i], td::crc32(t));
|
ASSERT_EQ(answers1[i], td::crc32(t));
|
||||||
state.init(as_slice(key), as_slice(iv));
|
state.init(as_slice(key), as_slice(iv));
|
||||||
pos = 0;
|
pos = 0;
|
||||||
for (auto str : td::rand_split(td::string(length, '\0'))) {
|
for (const auto &str : td::rand_split(td::string(length, '\0'))) {
|
||||||
auto len = str.size();
|
auto len = str.size();
|
||||||
state.decrypt(td::Slice(t).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
state.decrypt(td::Slice(t).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
||||||
pos += len;
|
pos += len;
|
||||||
@ -92,7 +92,7 @@ TEST(Crypto, AesCtrState) {
|
|||||||
}
|
}
|
||||||
state.init(as_slice(key), as_slice(iv));
|
state.init(as_slice(key), as_slice(iv));
|
||||||
pos = 0;
|
pos = 0;
|
||||||
for (auto str : td::rand_split(td::string(length, '\0'))) {
|
for (const auto &str : td::rand_split(td::string(length, '\0'))) {
|
||||||
auto len = str.size();
|
auto len = str.size();
|
||||||
state.encrypt(td::Slice(s).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
state.encrypt(td::Slice(s).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
||||||
pos += len;
|
pos += len;
|
||||||
@ -132,7 +132,7 @@ TEST(Crypto, AesIgeState) {
|
|||||||
td::UInt256 iv_copy = iv;
|
td::UInt256 iv_copy = iv;
|
||||||
td::string u(length, '\0');
|
td::string u(length, '\0');
|
||||||
std::size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
for (auto str : td::rand_split(td::string(length / 16, '\0'))) {
|
for (const auto &str : td::rand_split(td::string(length / 16, '\0'))) {
|
||||||
auto len = 16 * str.size();
|
auto len = 16 * str.size();
|
||||||
state.encrypt(td::Slice(s).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
state.encrypt(td::Slice(s).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
||||||
td::aes_ige_encrypt(as_slice(key), as_slice(iv_copy), td::Slice(s).substr(pos, len),
|
td::aes_ige_encrypt(as_slice(key), as_slice(iv_copy), td::Slice(s).substr(pos, len),
|
||||||
@ -146,7 +146,7 @@ TEST(Crypto, AesIgeState) {
|
|||||||
state.init(as_slice(key), as_slice(iv), false);
|
state.init(as_slice(key), as_slice(iv), false);
|
||||||
iv_copy = iv;
|
iv_copy = iv;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
for (auto str : td::rand_split(td::string(length / 16, '\0'))) {
|
for (const auto &str : td::rand_split(td::string(length / 16, '\0'))) {
|
||||||
auto len = 16 * str.size();
|
auto len = 16 * str.size();
|
||||||
state.decrypt(td::Slice(t).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
state.decrypt(td::Slice(t).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
||||||
td::aes_ige_decrypt(as_slice(key), as_slice(iv_copy), td::Slice(u).substr(pos, len),
|
td::aes_ige_decrypt(as_slice(key), as_slice(iv_copy), td::Slice(u).substr(pos, len),
|
||||||
@ -188,7 +188,7 @@ TEST(Crypto, AesCbcState) {
|
|||||||
td::UInt128 iv_copy = iv;
|
td::UInt128 iv_copy = iv;
|
||||||
td::string u(length, '\0');
|
td::string u(length, '\0');
|
||||||
std::size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
for (auto str : td::rand_split(td::string(length / 16, '\0'))) {
|
for (const auto &str : td::rand_split(td::string(length / 16, '\0'))) {
|
||||||
auto len = 16 * str.size();
|
auto len = 16 * str.size();
|
||||||
state.encrypt(td::Slice(s).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
state.encrypt(td::Slice(s).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
||||||
td::aes_cbc_encrypt(as_slice(key), as_slice(iv_copy), td::Slice(s).substr(pos, len),
|
td::aes_cbc_encrypt(as_slice(key), as_slice(iv_copy), td::Slice(s).substr(pos, len),
|
||||||
@ -202,7 +202,7 @@ TEST(Crypto, AesCbcState) {
|
|||||||
state = td::AesCbcState(as_slice(key), as_slice(iv));
|
state = td::AesCbcState(as_slice(key), as_slice(iv));
|
||||||
iv_copy = iv;
|
iv_copy = iv;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
for (auto str : td::rand_split(td::string(length / 16, '\0'))) {
|
for (const auto &str : td::rand_split(td::string(length / 16, '\0'))) {
|
||||||
auto len = 16 * str.size();
|
auto len = 16 * str.size();
|
||||||
state.decrypt(td::Slice(t).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
state.decrypt(td::Slice(t).substr(pos, len), td::MutableSlice(t).substr(pos, len));
|
||||||
td::aes_cbc_decrypt(as_slice(key), as_slice(iv_copy), td::Slice(u).substr(pos, len),
|
td::aes_cbc_decrypt(as_slice(key), as_slice(iv_copy), td::Slice(u).substr(pos, len),
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
static void encode_decode(td::string s) {
|
static void encode_decode(const td::string &s) {
|
||||||
auto r = td::gzencode(s, 2);
|
auto r = td::gzencode(s, 2);
|
||||||
ASSERT_TRUE(!r.empty());
|
ASSERT_TRUE(!r.empty());
|
||||||
ASSERT_EQ(s, td::gzdecode(r.as_slice()));
|
ASSERT_EQ(s, td::gzdecode(r.as_slice()));
|
||||||
@ -30,7 +30,7 @@ TEST(Gzip, gzencode_gzdecode) {
|
|||||||
encode_decode(td::string(1000000, 'a'));
|
encode_decode(td::string(1000000, 'a'));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_gzencode(td::string s) {
|
static void test_gzencode(const td::string &s) {
|
||||||
auto begin_time = td::Time::now();
|
auto begin_time = td::Time::now();
|
||||||
auto r = td::gzencode(s, td::max(2, static_cast<int>(100 / s.size())));
|
auto r = td::gzencode(s, td::max(2, static_cast<int>(100 / s.size())));
|
||||||
ASSERT_TRUE(!r.empty());
|
ASSERT_TRUE(!r.empty());
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
static void decode_encode(td::string str, td::string result = "") {
|
static void decode_encode(const td::string &str, td::string result = td::string()) {
|
||||||
auto str_copy = str;
|
auto str_copy = str;
|
||||||
auto r_value = td::json_decode(str_copy);
|
auto r_value = td::json_decode(str_copy);
|
||||||
ASSERT_TRUE(r_value.is_ok());
|
ASSERT_TRUE(r_value.is_ok());
|
||||||
|
@ -43,7 +43,7 @@ class LogBenchmark final : public td::Benchmark {
|
|||||||
threads_.resize(threads_n_);
|
threads_.resize(threads_n_);
|
||||||
}
|
}
|
||||||
void tear_down() final {
|
void tear_down() final {
|
||||||
for (auto path : log_->get_file_paths()) {
|
for (const auto &path : log_->get_file_paths()) {
|
||||||
td::unlink(path).ignore();
|
td::unlink(path).ignore();
|
||||||
}
|
}
|
||||||
log_.reset();
|
log_.reset();
|
||||||
|
@ -266,7 +266,7 @@ TEST(Misc, base64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static void test_remove_if(td::vector<int> v, const T &func, td::vector<int> expected) {
|
static void test_remove_if(td::vector<int> v, const T &func, const td::vector<int> &expected) {
|
||||||
td::remove_if(v, func);
|
td::remove_if(v, func);
|
||||||
if (expected != v) {
|
if (expected != v) {
|
||||||
LOG(FATAL) << "Receive " << v << ", expected " << expected << " in remove_if";
|
LOG(FATAL) << "Receive " << v << ", expected " << expected << " in remove_if";
|
||||||
@ -324,7 +324,7 @@ TEST(Misc, remove_if) {
|
|||||||
test_remove_if(v, none, v);
|
test_remove_if(v, none, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_remove(td::vector<int> v, int value, td::vector<int> expected) {
|
static void test_remove(td::vector<int> v, int value, const td::vector<int> &expected) {
|
||||||
bool is_found = expected != v;
|
bool is_found = expected != v;
|
||||||
ASSERT_EQ(is_found, td::remove(v, value));
|
ASSERT_EQ(is_found, td::remove(v, value));
|
||||||
if (expected != v) {
|
if (expected != v) {
|
||||||
@ -349,7 +349,7 @@ TEST(Misc, remove) {
|
|||||||
test_remove(v, 1, v);
|
test_remove(v, 1, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_unique(td::vector<int> v, td::vector<int> expected) {
|
static void test_unique(td::vector<int> v, const td::vector<int> &expected) {
|
||||||
auto v_str = td::transform(v, &td::to_string<int>);
|
auto v_str = td::transform(v, &td::to_string<int>);
|
||||||
auto expected_str = td::transform(expected, &td::to_string<int>);
|
auto expected_str = td::transform(expected, &td::to_string<int>);
|
||||||
|
|
||||||
@ -516,7 +516,7 @@ TEST(Misc, print_uint) {
|
|||||||
ASSERT_STREQ("9223372036854775807", PSLICE() << 9223372036854775807u);
|
ASSERT_STREQ("9223372036854775807", PSLICE() << 9223372036854775807u);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_idn_to_ascii_one(td::string host, td::string result) {
|
static void test_idn_to_ascii_one(const td::string &host, const td::string &result) {
|
||||||
if (result != td::idn_to_ascii(host).ok()) {
|
if (result != td::idn_to_ascii(host).ok()) {
|
||||||
LOG(ERROR) << "Failed to convert " << host << " to " << result << ", got \"" << td::idn_to_ascii(host).ok() << "\"";
|
LOG(ERROR) << "Failed to convert " << host << " to " << result << ", got \"" << td::idn_to_ascii(host).ok() << "\"";
|
||||||
}
|
}
|
||||||
@ -557,7 +557,7 @@ TEST(Misc, idn_to_ascii) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if TD_WINDOWS
|
#if TD_WINDOWS
|
||||||
static void test_to_wstring_one(td::string str) {
|
static void test_to_wstring_one(const td::string &str) {
|
||||||
ASSERT_STREQ(str, td::from_wstring(td::to_wstring(str).ok()).ok());
|
ASSERT_STREQ(str, td::from_wstring(td::to_wstring(str).ok()).ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,7 +589,7 @@ TEST(Misc, to_wstring) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void test_translit(td::string word, td::vector<td::string> result, bool allow_partial = true) {
|
static void test_translit(const td::string &word, const td::vector<td::string> &result, bool allow_partial = true) {
|
||||||
ASSERT_EQ(result, td::get_word_transliterations(word, allow_partial));
|
ASSERT_EQ(result, td::get_word_transliterations(word, allow_partial));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,7 +679,7 @@ TEST(Misc, IPAddress_get_ipv4) {
|
|||||||
test_get_ipv4(0xFFFFFFFF);
|
test_get_ipv4(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_is_reserved(td::string ip, bool is_reserved) {
|
static void test_is_reserved(const td::string &ip, bool is_reserved) {
|
||||||
td::IPAddress ip_address;
|
td::IPAddress ip_address;
|
||||||
ip_address.init_ipv4_port(ip, 80).ensure();
|
ip_address.init_ipv4_port(ip, 80).ensure();
|
||||||
ASSERT_EQ(is_reserved, ip_address.is_reserved());
|
ASSERT_EQ(is_reserved, ip_address.is_reserved());
|
||||||
@ -772,11 +772,11 @@ TEST(Misc, split) {
|
|||||||
test_split(" abcdef ", {"", "abcdef "});
|
test_split(" abcdef ", {"", "abcdef "});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_full_split(td::Slice str, td::vector<td::Slice> expected) {
|
static void test_full_split(td::Slice str, const td::vector<td::Slice> &expected) {
|
||||||
ASSERT_EQ(expected, td::full_split(str));
|
ASSERT_EQ(expected, td::full_split(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_full_split(td::Slice str, char c, std::size_t max_parts, td::vector<td::Slice> expected) {
|
static void test_full_split(td::Slice str, char c, std::size_t max_parts, const td::vector<td::Slice> &expected) {
|
||||||
ASSERT_EQ(expected, td::full_split(str, c, max_parts));
|
ASSERT_EQ(expected, td::full_split(str, c, max_parts));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -804,11 +804,12 @@ TEST(Misc, StringBuilder) {
|
|||||||
using V = td::vector<td::string>;
|
using V = td::vector<td::string>;
|
||||||
for (auto use_buf : {false, true}) {
|
for (auto use_buf : {false, true}) {
|
||||||
for (std::size_t initial_buffer_size : {0, 1, 5, 10, 100, 1000, 2000}) {
|
for (std::size_t initial_buffer_size : {0, 1, 5, 10, 100, 1000, 2000}) {
|
||||||
for (auto test : {V{small_str}, V{small_str, big_str, big_str, small_str}, V{big_str, small_str, big_str}}) {
|
for (const auto &test :
|
||||||
|
{V{small_str}, V{small_str, big_str, big_str, small_str}, V{big_str, small_str, big_str}}) {
|
||||||
td::string buf(initial_buffer_size, '\0');
|
td::string buf(initial_buffer_size, '\0');
|
||||||
td::StringBuilder sb(buf, use_buf);
|
td::StringBuilder sb(buf, use_buf);
|
||||||
td::string res;
|
td::string res;
|
||||||
for (auto x : test) {
|
for (const auto &x : test) {
|
||||||
res += x;
|
res += x;
|
||||||
sb << x;
|
sb << x;
|
||||||
}
|
}
|
||||||
@ -1046,9 +1047,11 @@ TEST(Misc, uint128) {
|
|||||||
if (b == 0) {
|
if (b == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
td::int64 q, r;
|
td::int64 q;
|
||||||
|
td::int64 r;
|
||||||
a.divmod_signed(b, &q, &r);
|
a.divmod_signed(b, &q, &r);
|
||||||
td::int64 iq, ir;
|
td::int64 iq;
|
||||||
|
td::int64 ir;
|
||||||
ia.divmod_signed(b, &iq, &ir);
|
ia.divmod_signed(b, &iq, &ir);
|
||||||
ASSERT_EQ(q, iq);
|
ASSERT_EQ(q, iq);
|
||||||
ASSERT_EQ(r, ir);
|
ASSERT_EQ(r, ir);
|
||||||
|
@ -77,7 +77,8 @@ static void test_pq(td::uint64 first, td::uint64 second) {
|
|||||||
td::BigNum::mul(pq, p, q, context);
|
td::BigNum::mul(pq, p, q, context);
|
||||||
td::string pq_str = pq.to_binary();
|
td::string pq_str = pq.to_binary();
|
||||||
|
|
||||||
td::string p_str, q_str;
|
td::string p_str;
|
||||||
|
td::string q_str;
|
||||||
int err = td::pq_factorize(pq_str, &p_str, &q_str);
|
int err = td::pq_factorize(pq_str, &p_str, &q_str);
|
||||||
LOG_CHECK(err == 0) << first << " * " << second;
|
LOG_CHECK(err == 0) << first << " * " << second;
|
||||||
|
|
||||||
|
@ -322,14 +322,14 @@ class SqliteKV {
|
|||||||
|
|
||||||
class BaselineKV {
|
class BaselineKV {
|
||||||
public:
|
public:
|
||||||
string get(string key) {
|
string get(const string &key) {
|
||||||
return map_[key];
|
return map_[key];
|
||||||
}
|
}
|
||||||
SeqNo set(string key, string value) {
|
SeqNo set(const string &key, string value) {
|
||||||
map_[key] = value;
|
map_[key] = std::move(value);
|
||||||
return ++current_tid_;
|
return ++current_tid_;
|
||||||
}
|
}
|
||||||
SeqNo erase(string key) {
|
SeqNo erase(const string &key) {
|
||||||
map_.erase(key);
|
map_.erase(key);
|
||||||
return ++current_tid_;
|
return ++current_tid_;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
using namespace td;
|
using namespace td;
|
||||||
|
|
||||||
static string make_chunked(string str) {
|
static string make_chunked(const string &str) {
|
||||||
auto v = rand_split(str);
|
auto v = rand_split(str);
|
||||||
string res;
|
string res;
|
||||||
for (auto &s : v) {
|
for (auto &s : v) {
|
||||||
@ -75,7 +75,7 @@ static string gen_http_content() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static string make_http_query(string content, bool is_json, bool is_chunked, bool is_gzip, double gzip_k = 5,
|
static string make_http_query(string content, bool is_json, bool is_chunked, bool is_gzip, double gzip_k = 5,
|
||||||
string zip_override = "") {
|
string zip_override = string()) {
|
||||||
HttpHeaderCreator hc;
|
HttpHeaderCreator hc;
|
||||||
hc.init_post("/");
|
hc.init_post("/");
|
||||||
hc.add_header("jfkdlsahhjk", rand_string('a', 'z', Random::fast(1, 2000)));
|
hc.add_header("jfkdlsahhjk", rand_string('a', 'z', Random::fast(1, 2000)));
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "td/utils/misc.h"
|
#include "td/utils/misc.h"
|
||||||
#include "td/utils/tests.h"
|
#include "td/utils/tests.h"
|
||||||
|
|
||||||
static void check_find_urls(td::string url, bool is_valid) {
|
static void check_find_urls(const td::string &url, bool is_valid) {
|
||||||
auto url_lower = td::to_lower(url);
|
auto url_lower = td::to_lower(url);
|
||||||
{
|
{
|
||||||
auto tg_urls = td::find_tg_urls(url);
|
auto tg_urls = td::find_tg_urls(url);
|
||||||
@ -35,7 +35,7 @@ static void check_find_urls(td::string url, bool is_valid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_link(td::string url, td::string expected) {
|
static void check_link(const td::string &url, const td::string &expected) {
|
||||||
auto result = td::LinkManager::check_link(url);
|
auto result = td::LinkManager::check_link(url);
|
||||||
if (result.is_ok()) {
|
if (result.is_ok()) {
|
||||||
ASSERT_STREQ(expected, result.ok());
|
ASSERT_STREQ(expected, result.ok());
|
||||||
@ -79,7 +79,7 @@ TEST(Link, check_link) {
|
|||||||
check_link("https://.", "");
|
check_link("https://.", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_internal_link(td::string url, td::td_api::object_ptr<td::td_api::InternalLinkType> expected) {
|
static void parse_internal_link(const td::string &url, td::td_api::object_ptr<td::td_api::InternalLinkType> expected) {
|
||||||
auto result = td::LinkManager::parse_internal_link(url);
|
auto result = td::LinkManager::parse_internal_link(url);
|
||||||
if (result != nullptr) {
|
if (result != nullptr) {
|
||||||
auto object = result->get_internal_link_type_object();
|
auto object = result->get_internal_link_type_object();
|
||||||
|
@ -1745,8 +1745,8 @@ TEST(MessageEntities, parse_markdown_v3) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_get_markdown_v3(td::string result_text, td::vector<td::MessageEntity> result_entities,
|
static void check_get_markdown_v3(const td::string &result_text, const td::vector<td::MessageEntity> &result_entities,
|
||||||
const td::string &text, const td::vector<td::MessageEntity> &entities) {
|
td::string text, td::vector<td::MessageEntity> entities) {
|
||||||
auto markdown_text = td::get_markdown_v3({std::move(text), std::move(entities)});
|
auto markdown_text = td::get_markdown_v3({std::move(text), std::move(entities)});
|
||||||
ASSERT_STREQ(result_text, markdown_text.text);
|
ASSERT_STREQ(result_text, markdown_text.text);
|
||||||
ASSERT_EQ(result_entities, markdown_text.entities);
|
ASSERT_EQ(result_entities, markdown_text.entities);
|
||||||
|
@ -95,11 +95,11 @@ TEST(Mtproto, GetHostByNameActor) {
|
|||||||
"2001:0db8:85a3:0000:0000:8a2e:0370:7334",
|
"2001:0db8:85a3:0000:0000:8a2e:0370:7334",
|
||||||
"[2001:0db8:85a3:0000:0000:8a2e:0370:7334]",
|
"[2001:0db8:85a3:0000:0000:8a2e:0370:7334]",
|
||||||
"[[2001:0db8:85a3:0000:0000:8a2e:0370:7334]]"};
|
"[[2001:0db8:85a3:0000:0000:8a2e:0370:7334]]"};
|
||||||
for (auto types : {vector<GetHostByNameActor::ResolverType>{GetHostByNameActor::ResolverType::Native},
|
for (const auto &types : {vector<GetHostByNameActor::ResolverType>{GetHostByNameActor::ResolverType::Native},
|
||||||
vector<GetHostByNameActor::ResolverType>{GetHostByNameActor::ResolverType::Google},
|
vector<GetHostByNameActor::ResolverType>{GetHostByNameActor::ResolverType::Google},
|
||||||
vector<GetHostByNameActor::ResolverType>{GetHostByNameActor::ResolverType::Google,
|
vector<GetHostByNameActor::ResolverType>{GetHostByNameActor::ResolverType::Google,
|
||||||
GetHostByNameActor::ResolverType::Google,
|
GetHostByNameActor::ResolverType::Google,
|
||||||
GetHostByNameActor::ResolverType::Native}}) {
|
GetHostByNameActor::ResolverType::Native}}) {
|
||||||
GetHostByNameActor::Options options;
|
GetHostByNameActor::Options options;
|
||||||
options.resolver_types = types;
|
options.resolver_types = types;
|
||||||
options.scheduler_id = threads_n;
|
options.scheduler_id = threads_n;
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/tests.h"
|
#include "td/utils/tests.h"
|
||||||
|
|
||||||
static void check_vote_percentage(std::vector<td::int32> voter_counts, td::int32 total_count,
|
static void check_vote_percentage(const std::vector<td::int32> &voter_counts, td::int32 total_count,
|
||||||
std::vector<td::int32> expected) {
|
const std::vector<td::int32> &expected) {
|
||||||
auto result = td::PollManager::get_vote_percentage(voter_counts, total_count);
|
auto result = td::PollManager::get_vote_percentage(voter_counts, total_count);
|
||||||
if (result != expected) {
|
if (result != expected) {
|
||||||
LOG(FATAL) << "Have " << voter_counts << " and " << total_count << ", but received " << result << " instead of "
|
LOG(FATAL) << "Have " << voter_counts << " and " << total_count << ", but received " << result << " instead of "
|
||||||
|
@ -764,15 +764,17 @@ class Master final : public Actor {
|
|||||||
bob_ = create_actor<SecretChatProxy>("SecretChatProxy bob", "bob", actor_shared(this, 2));
|
bob_ = create_actor<SecretChatProxy>("SecretChatProxy bob", "bob", actor_shared(this, 2));
|
||||||
send_closure(alice_->get_actor_unsafe()->actor_, &SecretChatActor::create_chat, UserId(static_cast<int64>(2)), 0,
|
send_closure(alice_->get_actor_unsafe()->actor_, &SecretChatActor::create_chat, UserId(static_cast<int64>(2)), 0,
|
||||||
123, PromiseCreator::lambda([actor_id = actor_id(this)](Result<SecretChatId> res) {
|
123, PromiseCreator::lambda([actor_id = actor_id(this)](Result<SecretChatId> res) {
|
||||||
send_closure(actor_id, &Master::got_secret_chat_id, std::move(res), 0);
|
send_closure(actor_id, &Master::got_secret_chat_id, std::move(res), false);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
void got_secret_chat_id(Result<SecretChatId> res, int) { // second parameter is needed to workaround clang bug
|
|
||||||
|
void got_secret_chat_id(Result<SecretChatId> res, bool dummy) {
|
||||||
CHECK(res.is_ok());
|
CHECK(res.is_ok());
|
||||||
auto id = res.move_as_ok();
|
auto id = res.move_as_ok();
|
||||||
LOG(INFO) << "SecretChatId = " << id;
|
LOG(INFO) << "SecretChatId = " << id;
|
||||||
}
|
}
|
||||||
bool can_fail(NetQueryPtr &query) {
|
|
||||||
|
static bool can_fail(NetQueryPtr &query) {
|
||||||
static int cnt = 20;
|
static int cnt = 20;
|
||||||
if (cnt > 0) {
|
if (cnt > 0) {
|
||||||
cnt--;
|
cnt--;
|
||||||
@ -784,6 +786,7 @@ class Master final : public Actor {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_net_query(NetQueryPtr query, ActorShared<NetQueryCallback> callback, bool ordered) {
|
void send_net_query(NetQueryPtr query, ActorShared<NetQueryCallback> callback, bool ordered) {
|
||||||
if (can_fail(query) && Random::fast_bool()) {
|
if (can_fail(query) && Random::fast_bool()) {
|
||||||
LOG(INFO) << "Fail query " << query;
|
LOG(INFO) << "Fail query " << query;
|
||||||
|
@ -36,7 +36,7 @@ TEST(StringCleaning, clean_username) {
|
|||||||
ASSERT_EQ("asd", clean_username(". ASD .."));
|
ASSERT_EQ("asd", clean_username(". ASD .."));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_clean_input_string(string str, string expected, bool expected_result) {
|
static void check_clean_input_string(string str, const string &expected, bool expected_result) {
|
||||||
auto result = clean_input_string(str);
|
auto result = clean_input_string(str);
|
||||||
ASSERT_EQ(expected_result, result);
|
ASSERT_EQ(expected_result, result);
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -73,8 +73,9 @@ TEST(StringCleaning, clean_input_string) {
|
|||||||
check_clean_input_string("\xcc\xb3\xcc\xbf\xcc\x8a", "", true);
|
check_clean_input_string("\xcc\xb3\xcc\xbf\xcc\x8a", "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_strip_empty_characters(string str, size_t max_length, string expected, bool strip_rtlo = false) {
|
static void check_strip_empty_characters(string str, size_t max_length, const string &expected,
|
||||||
ASSERT_EQ(expected, strip_empty_characters(str, max_length, strip_rtlo));
|
bool strip_rtlo = false) {
|
||||||
|
ASSERT_EQ(expected, strip_empty_characters(std::move(str), max_length, strip_rtlo));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringCleaning, strip_empty_characters) {
|
TEST(StringCleaning, strip_empty_characters) {
|
||||||
|
@ -568,7 +568,8 @@ class TestFileGenerated final : public TestClinetTask {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void generate_file(td::int64 id, td::string original_path, td::string destination_path, td::string conversion) {
|
void generate_file(td::int64 id, const td::string &original_path, const td::string &destination_path,
|
||||||
|
const td::string &conversion) {
|
||||||
LOG(ERROR) << "Generate file " << td::tag("id", id) << td::tag("original_path", original_path)
|
LOG(ERROR) << "Generate file " << td::tag("id", id) << td::tag("original_path", original_path)
|
||||||
<< td::tag("destination_path", destination_path) << td::tag("conversion", conversion);
|
<< td::tag("destination_path", destination_path) << td::tag("conversion", conversion);
|
||||||
if (conversion == "square") {
|
if (conversion == "square") {
|
||||||
|
@ -100,7 +100,7 @@ class TestTQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventId push(td::TQueue::QueueId queue_id, td::string data, td::int32 expires_at, EventId new_id = EventId()) {
|
EventId push(td::TQueue::QueueId queue_id, const td::string &data, td::int32 expires_at, EventId new_id = EventId()) {
|
||||||
auto a_id = baseline_->push(queue_id, data, expires_at, 0, new_id).move_as_ok();
|
auto a_id = baseline_->push(queue_id, data, expires_at, 0, new_id).move_as_ok();
|
||||||
auto b_id = memory_->push(queue_id, data, expires_at, 0, new_id).move_as_ok();
|
auto b_id = memory_->push(queue_id, data, expires_at, 0, new_id).move_as_ok();
|
||||||
auto c_id = binlog_->push(queue_id, data, expires_at, 0, new_id).move_as_ok();
|
auto c_id = binlog_->push(queue_id, data, expires_at, 0, new_id).move_as_ok();
|
||||||
|
Loading…
Reference in New Issue
Block a user