Replace unsafe to maintain data_ field with get_data() method.
This commit is contained in:
parent
2a5f6121ef
commit
882de6e8e8
@ -127,7 +127,7 @@ void on_save_app_log_binlog_event(Td *td, BinlogEvent &&event) {
|
||||
CHECK(event.id_ != 0);
|
||||
CHECK(event.type_ == LogEvent::HandlerType::SaveAppLog);
|
||||
SaveAppLogLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
save_app_log_impl(td, std::move(log_event.input_app_event_out_), event.id_, Promise<Unit>());
|
||||
}
|
||||
|
@ -9979,7 +9979,7 @@ void ContactsManager::on_binlog_user_event(BinlogEvent &&event) {
|
||||
}
|
||||
|
||||
UserLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto user_id = log_event.user_id;
|
||||
if (have_min_user(user_id) || !user_id.is_valid()) {
|
||||
@ -10303,7 +10303,7 @@ void ContactsManager::on_binlog_chat_event(BinlogEvent &&event) {
|
||||
}
|
||||
|
||||
ChatLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto chat_id = log_event.chat_id;
|
||||
if (have_chat(chat_id) || !chat_id.is_valid()) {
|
||||
@ -10542,7 +10542,7 @@ void ContactsManager::on_binlog_channel_event(BinlogEvent &&event) {
|
||||
}
|
||||
|
||||
ChannelLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto channel_id = log_event.channel_id;
|
||||
if (have_channel(channel_id) || !channel_id.is_valid()) {
|
||||
@ -10797,7 +10797,7 @@ void ContactsManager::on_binlog_secret_chat_event(BinlogEvent &&event) {
|
||||
}
|
||||
|
||||
SecretChatLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto secret_chat_id = log_event.secret_chat_id;
|
||||
if (have_secret_chat(secret_chat_id) || !secret_chat_id.is_valid()) {
|
||||
|
@ -40415,14 +40415,14 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
SendMessageLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id;
|
||||
auto m = std::move(log_event.m_out);
|
||||
m->send_message_log_event_id = event.id_;
|
||||
|
||||
if (m->content->get_type() == MessageContentType::Unsupported) {
|
||||
LOG(ERROR) << "Message content is invalid: " << format::as_hex_dump<4>(Slice(event.data_));
|
||||
LOG(ERROR) << "Message content is invalid: " << format::as_hex_dump<4>(event.get_data());
|
||||
binlog_erase(G()->td_db()->get_binlog(), event.id_);
|
||||
continue;
|
||||
}
|
||||
@ -40456,7 +40456,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
SendBotStartMessageLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id;
|
||||
auto m = std::move(log_event.m_out);
|
||||
@ -40496,14 +40496,14 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
SendInlineQueryResultMessageLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id;
|
||||
auto m = std::move(log_event.m_out);
|
||||
m->send_message_log_event_id = event.id_;
|
||||
|
||||
if (m->content->get_type() == MessageContentType::Unsupported) {
|
||||
LOG(ERROR) << "Message content is invalid: " << format::as_hex_dump<4>(Slice(event.data_));
|
||||
LOG(ERROR) << "Message content is invalid: " << format::as_hex_dump<4>(event.get_data());
|
||||
binlog_erase(G()->td_db()->get_binlog(), event.id_);
|
||||
continue;
|
||||
}
|
||||
@ -40536,7 +40536,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
SendScreenshotTakenNotificationMessageLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id;
|
||||
auto m = std::move(log_event.m_out);
|
||||
@ -40569,7 +40569,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ForwardMessagesLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto to_dialog_id = log_event.to_dialog_id;
|
||||
auto from_dialog_id = log_event.from_dialog_id;
|
||||
@ -40649,7 +40649,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
DeleteMessageLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
log_event.id_ = event.id_;
|
||||
|
||||
Dialog *d = get_dialog_force(log_event.full_message_id_.get_dialog_id(), "DeleteMessageLogEvent");
|
||||
@ -40672,7 +40672,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
DeleteMessagesOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "DeleteMessagesOnServerLogEvent");
|
||||
@ -40696,7 +40696,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
DeleteScheduledMessagesOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "DeleteScheduledMessagesOnServerLogEvent");
|
||||
@ -40720,7 +40720,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
DeleteDialogHistoryOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "DeleteDialogHistoryOnServerLogEvent");
|
||||
@ -40740,7 +40740,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
DeleteTopicHistoryOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "DeleteTopicHistoryOnServerLogEvent");
|
||||
@ -40754,14 +40754,14 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
case LogEvent::HandlerType::DeleteAllCallMessagesOnServer: {
|
||||
DeleteAllCallMessagesOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
delete_all_call_messages_on_server(log_event.revoke_, event.id_, Auto());
|
||||
break;
|
||||
}
|
||||
case LogEvent::HandlerType::BlockMessageSenderFromRepliesOnServer: {
|
||||
BlockMessageSenderFromRepliesOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
block_message_sender_from_replies_on_server(log_event.message_id_, log_event.delete_message_,
|
||||
log_event.delete_all_messages_, log_event.report_spam_, event.id_,
|
||||
@ -40775,7 +40775,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
DeleteAllChannelMessagesFromSenderOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto channel_id = log_event.channel_id_;
|
||||
if (!td_->contacts_manager_->have_channel_force(channel_id)) {
|
||||
@ -40801,7 +40801,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
DeleteDialogMessagesByDateOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "DeleteDialogMessagesByDateOnServerLogEvent");
|
||||
@ -40821,7 +40821,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ReadHistoryOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "ReadHistoryOnServerLogEvent");
|
||||
@ -40840,7 +40840,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
case LogEvent::HandlerType::ReadHistoryInSecretChat: {
|
||||
ReadHistoryInSecretChatLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
CHECK(dialog_id.get_type() == DialogType::SecretChat);
|
||||
@ -40872,7 +40872,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ReadMessageThreadHistoryOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "ReadMessageThreadHistoryOnServerLogEvent");
|
||||
@ -40898,7 +40898,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ReadMessageContentsOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "ReadMessageContentsOnServerLogEvent");
|
||||
@ -40917,7 +40917,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ReadAllDialogMentionsOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "ReadAllDialogMentionsOnServerLogEvent");
|
||||
@ -40936,7 +40936,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ReadAllDialogReactionsOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "ReadAllDialogReactionsOnServerLogEvent");
|
||||
@ -40955,7 +40955,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ToggleDialogIsPinnedOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "ToggleDialogIsPinnedOnServerLogEvent");
|
||||
@ -40974,7 +40974,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ReorderPinnedDialogsOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
vector<DialogId> dialog_ids;
|
||||
for (auto &dialog_id : log_event.dialog_ids_) {
|
||||
@ -40998,7 +40998,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ToggleDialogIsMarkedAsUnreadOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
bool have_info = dialog_id.get_type() == DialogType::User
|
||||
@ -41019,7 +41019,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ToggleDialogIsBlockedOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
if (dialog_id.get_type() == DialogType::SecretChat || !have_dialog_info_force(dialog_id) ||
|
||||
@ -41038,7 +41038,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
SaveDialogDraftMessageOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "SaveDialogDraftMessageOnServerLogEvent");
|
||||
@ -41058,7 +41058,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
UpdateDialogNotificationSettingsOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "UpdateDialogNotificationSettingsOnServerLogEvent");
|
||||
@ -41073,7 +41073,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
case LogEvent::HandlerType::ResetAllNotificationSettingsOnServer: {
|
||||
ResetAllNotificationSettingsOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
reset_all_notification_settings_on_server(event.id_);
|
||||
break;
|
||||
@ -41085,7 +41085,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
ToggleDialogReportSpamStateOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "ToggleDialogReportSpamStateOnServerLogEvent");
|
||||
@ -41104,7 +41104,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
SetDialogFolderIdOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dialog *d = get_dialog_force(dialog_id, "SetDialogFolderIdOnServerLogEvent");
|
||||
@ -41126,7 +41126,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
RegetDialogLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.dialog_id_;
|
||||
Dependencies dependencies;
|
||||
@ -41150,7 +41150,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
UnpinAllDialogMessagesOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
unpin_all_dialog_messages_on_server(log_event.dialog_id_, event.id_, Auto());
|
||||
break;
|
||||
@ -41162,7 +41162,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
GetChannelDifferenceLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
DialogId dialog_id(log_event.channel_id);
|
||||
if (dialog_id.get_type() != DialogType::Channel) {
|
||||
|
@ -4186,7 +4186,7 @@ void NotificationManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
case LogEvent::HandlerType::AddMessagePushNotification: {
|
||||
CHECK(is_inited_);
|
||||
AddMessagePushNotificationLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
add_message_push_notification(
|
||||
log_event.dialog_id_, log_event.message_id_, log_event.random_id_, log_event.sender_user_id_,
|
||||
@ -4203,7 +4203,7 @@ void NotificationManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
case LogEvent::HandlerType::EditMessagePushNotification: {
|
||||
CHECK(is_inited_);
|
||||
EditMessagePushNotificationLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
edit_message_push_notification(
|
||||
log_event.dialog_id_, log_event.message_id_, log_event.edit_date_, log_event.loc_key_, log_event.arg_,
|
||||
|
@ -1493,7 +1493,7 @@ void NotificationSettingsManager::on_binlog_events(vector<BinlogEvent> &&events)
|
||||
switch (event.type_) {
|
||||
case LogEvent::HandlerType::UpdateScopeNotificationSettingsOnServer: {
|
||||
UpdateScopeNotificationSettingsOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
update_scope_notification_settings_on_server(log_event.scope_, event.id_);
|
||||
break;
|
||||
|
@ -1822,7 +1822,7 @@ void PollManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
SetPollAnswerLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.full_message_id_.get_dialog_id();
|
||||
|
||||
@ -1841,7 +1841,7 @@ void PollManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
StopPollLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto dialog_id = log_event.full_message_id_.get_dialog_id();
|
||||
|
||||
|
@ -1563,7 +1563,7 @@ void WebPagesManager::on_binlog_web_page_event(BinlogEvent &&event) {
|
||||
}
|
||||
|
||||
WebPageLogEvent log_event;
|
||||
log_event_parse(log_event, event.data_).ensure();
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
auto web_page_id = log_event.web_page_id;
|
||||
if (!web_page_id.is_valid()) {
|
||||
|
@ -82,7 +82,7 @@ class BinlogKeyValue final : public KeyValueSyncInterface {
|
||||
name,
|
||||
[&](const BinlogEvent &binlog_event) {
|
||||
Event event;
|
||||
event.parse(TlParser(binlog_event.data_));
|
||||
event.parse(TlParser(binlog_event.get_data()));
|
||||
map_.emplace(event.key.str(), std::make_pair(event.value.str(), binlog_event.id_));
|
||||
},
|
||||
std::move(db_key), DbKey::empty(), scheduler_id));
|
||||
@ -103,7 +103,7 @@ class BinlogKeyValue final : public KeyValueSyncInterface {
|
||||
|
||||
void external_init_handle(const BinlogEvent &binlog_event) {
|
||||
Event event;
|
||||
event.parse(TlParser(binlog_event.data_));
|
||||
event.parse(TlParser(binlog_event.get_data()));
|
||||
map_.emplace(event.key.str(), std::make_pair(event.value.str(), binlog_event.id_));
|
||||
}
|
||||
|
||||
|
@ -550,7 +550,7 @@ void TQueueBinlog<BinlogT>::pop(uint64 log_event_id) {
|
||||
template <class BinlogT>
|
||||
Status TQueueBinlog<BinlogT>::replay(const BinlogEvent &binlog_event, TQueue &q) const {
|
||||
TQueueLogEvent event;
|
||||
TlParser parser(binlog_event.data_);
|
||||
TlParser parser(binlog_event.get_data());
|
||||
int32 has_extra = binlog_event.type_ - BINLOG_EVENT_TYPE;
|
||||
if (has_extra != 0 && has_extra != 1) {
|
||||
return Status::Error("Wrong magic");
|
||||
|
@ -345,7 +345,7 @@ void Binlog::do_event(BinlogEvent &&event) {
|
||||
if (event.type_ < 0) {
|
||||
if (event.type_ == BinlogEvent::ServiceTypes::AesCtrEncryption) {
|
||||
detail::AesCtrEncryptionEvent encryption_event;
|
||||
encryption_event.parse(TlParser(event.data_));
|
||||
encryption_event.parse(TlParser(event.get_data()));
|
||||
|
||||
string key;
|
||||
if (aes_ctr_key_salt_ == encryption_event.key_salt_) {
|
||||
|
@ -23,8 +23,7 @@ Status BinlogEvent::init(BufferSlice &&raw_event, bool check_crc) {
|
||||
flags_ = parser.fetch_int();
|
||||
extra_ = parser.fetch_long();
|
||||
CHECK(size_ >= MIN_SIZE);
|
||||
auto slice_data = parser.fetch_string_raw<Slice>(size_ - MIN_SIZE);
|
||||
data_ = MutableSlice(const_cast<char *>(slice_data.begin()), slice_data.size());
|
||||
parser.fetch_string_raw<Slice>(size_ - MIN_SIZE); // skip data
|
||||
crc32_ = static_cast<uint32>(parser.fetch_int());
|
||||
if (check_crc) {
|
||||
auto calculated_crc = crc32(raw_event.as_slice().substr(0, size_ - TAIL_SIZE));
|
||||
@ -37,6 +36,10 @@ Status BinlogEvent::init(BufferSlice &&raw_event, bool check_crc) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Slice BinlogEvent::get_data() const {
|
||||
return Slice(raw_event_.as_slice().data() + HEADER_SIZE, size_ - MIN_SIZE);
|
||||
}
|
||||
|
||||
Status BinlogEvent::validate() const {
|
||||
BinlogEvent event;
|
||||
if (raw_event_.size() < 4) {
|
||||
@ -69,10 +72,7 @@ BufferSlice BinlogEvent::create_raw(uint64 id, int32 type, int32 flags, const St
|
||||
}
|
||||
|
||||
void BinlogEvent::realloc() {
|
||||
auto data_offset = data_.begin() - raw_event_.as_slice().begin();
|
||||
auto data_size = data_.size();
|
||||
raw_event_ = raw_event_.copy();
|
||||
data_ = raw_event_.as_slice().substr(data_offset, data_size);
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -60,7 +60,6 @@ struct BinlogEvent {
|
||||
int32 type_; // type can be merged with flags
|
||||
int32 flags_;
|
||||
uint64 extra_;
|
||||
MutableSlice data_;
|
||||
uint32 crc32_;
|
||||
|
||||
BufferSlice raw_event_;
|
||||
@ -70,6 +69,8 @@ struct BinlogEvent {
|
||||
enum ServiceTypes { Header = -1, Empty = -2, AesCtrEncryption = -3, NoEncryption = -4 };
|
||||
enum Flags { Rewrite = 1, Partial = 2 };
|
||||
|
||||
Slice get_data() const;
|
||||
|
||||
void clear() {
|
||||
raw_event_ = BufferSlice();
|
||||
}
|
||||
@ -84,7 +85,7 @@ struct BinlogEvent {
|
||||
}
|
||||
|
||||
BufferSlice data_as_buffer_slice() const {
|
||||
return raw_event_.from_slice(data_);
|
||||
return raw_event_.from_slice(get_data());
|
||||
}
|
||||
|
||||
BinlogEvent() = default;
|
||||
@ -102,7 +103,7 @@ struct BinlogEvent {
|
||||
|
||||
std::string public_to_string() const {
|
||||
return PSTRING() << "LogEvent[" << tag("id", format::as_hex(id_)) << tag("type", type_) << tag("flags", flags_)
|
||||
<< tag("data", data_.size()) << "]" << debug_info_;
|
||||
<< tag("data", get_data().size()) << "]" << debug_info_;
|
||||
}
|
||||
|
||||
Status validate() const;
|
||||
@ -112,7 +113,7 @@ struct BinlogEvent {
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &sb, const BinlogEvent &event) {
|
||||
return sb << "LogEvent[" << tag("id", format::as_hex(event.id_)) << tag("type", event.type_)
|
||||
<< tag("flags", event.flags_) << tag("data", format::as_hex_dump<4>(event.data_)) << "]"
|
||||
<< tag("flags", event.flags_) << tag("data", format::as_hex_dump<4>(event.get_data())) << "]"
|
||||
<< event.debug_info_;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ int main(int argc, char *argv[]) {
|
||||
info[0].compressed_size += event.raw_event_.size();
|
||||
info[event.type_].compressed_size += event.raw_event_.size();
|
||||
if (event.type_ == ConfigPmcMagic || event.type_ == BinlogPmcMagic) {
|
||||
auto key = td::TlParser(event.data_).fetch_string<td::Slice>();
|
||||
auto key = td::TlParser(event.get_data()).fetch_string<td::Slice>();
|
||||
info[event.type_].compressed_trie.add(key);
|
||||
}
|
||||
},
|
||||
@ -134,13 +134,13 @@ int main(int argc, char *argv[]) {
|
||||
info[0].full_size += event.raw_event_.size();
|
||||
info[event.type_].full_size += event.raw_event_.size();
|
||||
if (event.type_ == ConfigPmcMagic || event.type_ == BinlogPmcMagic) {
|
||||
auto key = td::TlParser(event.data_).fetch_string<td::Slice>();
|
||||
auto key = td::TlParser(event.get_data()).fetch_string<td::Slice>();
|
||||
info[event.type_].trie.add(key);
|
||||
}
|
||||
LOG(PLAIN) << "LogEvent[" << td::tag("event_id", td::format::as_hex(event.id_))
|
||||
<< td::tag("type", event.type_) << td::tag("flags", event.flags_)
|
||||
<< td::tag("size", event.data_.size()) << td::tag("data", td::format::escaped(event.data_))
|
||||
<< "]\n";
|
||||
<< td::tag("size", event.get_data().size())
|
||||
<< td::tag("data", td::format::escaped(event.get_data())) << "]\n";
|
||||
})
|
||||
.ensure();
|
||||
|
||||
|
@ -25,7 +25,7 @@ class BinlogEventsBuffer {
|
||||
auto &event = events_[i];
|
||||
if (i + 1 != ids_.size() && (event.flags_ & BinlogEvent::Flags::Partial) == 0) {
|
||||
callback(BinlogEvent(BinlogEvent::create_raw(event.id_, event.type_, event.flags_ | BinlogEvent::Flags::Partial,
|
||||
create_storer(event.data_)),
|
||||
create_storer(event.get_data())),
|
||||
BinlogDebugInfo{__FILE__, __LINE__}));
|
||||
} else {
|
||||
callback(std::move(event));
|
||||
|
@ -105,7 +105,7 @@ TEST(DB, binlog_encryption) {
|
||||
td::Binlog binlog;
|
||||
binlog
|
||||
.init(
|
||||
binlog_name.str(), [&](const td::BinlogEvent &x) { v.push_back(x.data_.str()); }, hello)
|
||||
binlog_name.str(), [&](const td::BinlogEvent &x) { v.push_back(x.get_data().str()); }, hello)
|
||||
.ensure();
|
||||
CHECK(v == td::vector<td::string>({"AAAA", "BBBB", long_data, "CCCC"}));
|
||||
}
|
||||
@ -117,7 +117,7 @@ TEST(DB, binlog_encryption) {
|
||||
LOG(INFO) << "RESTART";
|
||||
td::Binlog binlog;
|
||||
auto status = binlog.init(
|
||||
binlog_name.str(), [&](const td::BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber);
|
||||
binlog_name.str(), [&](const td::BinlogEvent &x) { v.push_back(x.get_data().str()); }, cucumber);
|
||||
CHECK(status.is_error());
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ TEST(DB, binlog_encryption) {
|
||||
LOG(INFO) << "RESTART";
|
||||
td::Binlog binlog;
|
||||
auto status = binlog.init(
|
||||
binlog_name.str(), [&](const td::BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber, hello);
|
||||
binlog_name.str(), [&](const td::BinlogEvent &x) { v.push_back(x.get_data().str()); }, cucumber, hello);
|
||||
CHECK(v == td::vector<td::string>({"AAAA", "BBBB", long_data, "CCCC"}));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user