1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

updated liteserver

- new methods for liteserver/liteclient
- added ADNL/DHT client-only work mode
- fixed crash in ADNL
This commit is contained in:
ton 2020-02-02 16:53:37 +04:00
parent acf16718e6
commit 53ec9684bd
70 changed files with 816 additions and 322 deletions

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP
Copyright 2017-2020 Telegram Systems LLP
*/
#include "keyring.hpp"
#include "common/errorcode.h"
@ -28,7 +28,9 @@ namespace ton {
namespace keyring {
void KeyringImpl::start_up() {
td::mkdir(db_root_).ensure();
if (db_root_.size() > 0) {
td::mkdir(db_root_).ensure();
}
}
td::Result<KeyringImpl::PrivateKeyDescr *> KeyringImpl::load_key(PublicKeyHash key_hash) {
@ -37,6 +39,10 @@ td::Result<KeyringImpl::PrivateKeyDescr *> KeyringImpl::load_key(PublicKeyHash k
return it->second.get();
}
if (db_root_.size() == 0) {
return td::Status::Error(ErrorCode::notready, "key not in db");
}
auto name = db_root_ + "/" + key_hash.bits256_value().to_hex();
auto R = td::read_file(td::CSlice{name});
@ -67,6 +73,9 @@ void KeyringImpl::add_key(PrivateKey key, bool is_temp, td::Promise<td::Unit> pr
promise.set_value(td::Unit());
return;
}
if (db_root_.size() == 0) {
CHECK(is_temp);
}
auto D = key.create_decryptor_async();
D.ensure();
@ -103,6 +112,9 @@ void KeyringImpl::add_key_short(PublicKeyHash key_hash, td::Promise<PublicKey> p
void KeyringImpl::del_key(PublicKeyHash key_hash, td::Promise<td::Unit> promise) {
map_.erase(key_hash);
if (db_root_.size() == 0) {
return promise.set_value(td::Unit());
}
auto name = db_root_ + "/" + key_hash.bits256_value().to_hex();
td::BufferSlice d{256};
td::Random::secure_bytes(d.as_slice());