Add static AuthDataShared::get_auth_key_for_dc().
This commit is contained in:
parent
4786d1a931
commit
d5f7423b52
@ -34,8 +34,8 @@ class AuthDataSharedImpl final : public AuthDataShared {
|
||||
return public_rsa_key_;
|
||||
}
|
||||
|
||||
mtproto::AuthKey get_auth_key() final {
|
||||
string dc_key = G()->td_db()->get_binlog_pmc()->get(auth_key_key());
|
||||
static mtproto::AuthKey get_auth_key_for_dc(DcId dc_id) {
|
||||
string dc_key = G()->td_db()->get_binlog_pmc()->get(get_auth_key_binlog_key(dc_id));
|
||||
|
||||
mtproto::AuthKey res;
|
||||
if (!dc_key.empty()) {
|
||||
@ -44,8 +44,12 @@ class AuthDataSharedImpl final : public AuthDataShared {
|
||||
return res;
|
||||
}
|
||||
|
||||
mtproto::AuthKey get_auth_key() final {
|
||||
return get_auth_key_for_dc(dc_id_);
|
||||
}
|
||||
|
||||
void set_auth_key(const mtproto::AuthKey &auth_key) final {
|
||||
G()->td_db()->get_binlog_pmc()->set(auth_key_key(), serialize(auth_key));
|
||||
G()->td_db()->get_binlog_pmc()->set(get_auth_key_binlog_key(dc_id_), serialize(auth_key));
|
||||
log_auth_key(auth_key);
|
||||
|
||||
notify();
|
||||
@ -69,11 +73,11 @@ class AuthDataSharedImpl final : public AuthDataShared {
|
||||
}
|
||||
|
||||
void set_future_salts(const std::vector<mtproto::ServerSalt> &future_salts) final {
|
||||
G()->td_db()->get_binlog_pmc()->set(future_salts_key(), serialize(future_salts));
|
||||
G()->td_db()->get_binlog_pmc()->set(get_future_salts_binlog_key(dc_id_), serialize(future_salts));
|
||||
}
|
||||
|
||||
std::vector<mtproto::ServerSalt> get_future_salts() final {
|
||||
string future_salts = G()->td_db()->get_binlog_pmc()->get(future_salts_key());
|
||||
string future_salts = G()->td_db()->get_binlog_pmc()->get(get_future_salts_binlog_key(dc_id_));
|
||||
std::vector<mtproto::ServerSalt> res;
|
||||
if (!future_salts.empty()) {
|
||||
unserialize(res, future_salts).ensure();
|
||||
@ -88,11 +92,12 @@ class AuthDataSharedImpl final : public AuthDataShared {
|
||||
std::shared_ptr<Guard> guard_;
|
||||
RwMutex rw_mutex_;
|
||||
|
||||
string auth_key_key() const {
|
||||
return PSTRING() << "auth" << dc_id_.get_raw_id();
|
||||
static string get_auth_key_binlog_key(DcId dc_id) {
|
||||
return PSTRING() << "auth" << dc_id.get_raw_id();
|
||||
}
|
||||
string future_salts_key() const {
|
||||
return PSTRING() << "salt" << dc_id_.get_raw_id();
|
||||
|
||||
static string get_future_salts_binlog_key(DcId dc_id) {
|
||||
return PSTRING() << "salt" << dc_id.get_raw_id();
|
||||
}
|
||||
|
||||
void notify() {
|
||||
@ -114,6 +119,10 @@ class AuthDataSharedImpl final : public AuthDataShared {
|
||||
}
|
||||
};
|
||||
|
||||
mtproto::AuthKey AuthDataShared::get_auth_key_for_dc(DcId dc_id) {
|
||||
return AuthDataSharedImpl::get_auth_key_for_dc(dc_id);
|
||||
}
|
||||
|
||||
std::shared_ptr<AuthDataShared> AuthDataShared::create(DcId dc_id, std::shared_ptr<PublicRsaKeyShared> public_rsa_key,
|
||||
std::shared_ptr<Guard> guard) {
|
||||
return std::make_shared<AuthDataSharedImpl>(dc_id, std::move(public_rsa_key), std::move(guard));
|
||||
|
@ -43,6 +43,8 @@ class AuthDataShared {
|
||||
virtual void set_future_salts(const std::vector<mtproto::ServerSalt> &future_salts) = 0;
|
||||
virtual std::vector<mtproto::ServerSalt> get_future_salts() = 0;
|
||||
|
||||
static mtproto::AuthKey get_auth_key_for_dc(DcId dc_id);
|
||||
|
||||
static std::shared_ptr<AuthDataShared> create(DcId dc_id, std::shared_ptr<PublicRsaKeyShared> public_rsa_key,
|
||||
std::shared_ptr<Guard> guard);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user