Skip to content

Commit

Permalink
Use keyStoreTypeDirectory in rldp-http-proxy and storage-daemon
Browse files Browse the repository at this point in the history
Mainly for caching synced block in tonlib.
  • Loading branch information
SpyCheese committed Jun 29, 2023
1 parent 53be89f commit 92f8ded
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 15 additions & 1 deletion rldp-http-proxy/rldp-http-proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "git.h"
#include "td/utils/BufferedFd.h"
#include "common/delay.h"
#include "td/utils/port/path.h"

#include "tonlib/tonlib/TonlibClientWrapper.h"
#include "DNSResolver.h"
Expand Down Expand Up @@ -920,6 +921,12 @@ class RldpHttpProxy : public td::actor::Actor {
}

void run() {
if (!db_root_.empty()) {
td::mkpath(db_root_ + "/").ensure();
} else if (!is_client_) {
LOG(ERROR) << "DB root is required for server proxy";
std::_Exit(2);
}
keyring_ = ton::keyring::Keyring::create(is_client_ ? std::string("") : (db_root_ + "/keyring"));
{
auto S = load_global_config();
Expand Down Expand Up @@ -955,9 +962,16 @@ class RldpHttpProxy : public td::actor::Actor {
auto conf_dataR = td::read_file(global_config_);
conf_dataR.ensure();

ton::tl_object_ptr<tonlib_api::KeyStoreType> key_store;
if (db_root_.empty()) {
key_store = tonlib_api::make_object<tonlib_api::keyStoreTypeInMemory>();
} else {
td::mkpath(db_root_ + "/tonlib-cache/").ensure();
key_store = tonlib_api::make_object<tonlib_api::keyStoreTypeDirectory>(db_root_ + "/tonlib-cache/");
}
auto tonlib_options = tonlib_api::make_object<tonlib_api::options>(
tonlib_api::make_object<tonlib_api::config>(conf_dataR.move_as_ok().as_slice().str(), "", false, false),
tonlib_api::make_object<tonlib_api::keyStoreTypeInMemory>());
std::move(key_store));
tonlib_client_ = td::actor::create_actor<tonlib::TonlibClientWrapper>("tonlibclient", std::move(tonlib_options));
dns_resolver_ = td::actor::create_actor<DNSResolver>("dnsresolver", tonlib_client_.get());
}
Expand Down
4 changes: 3 additions & 1 deletion storage/storage-daemon/storage-daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,9 +927,11 @@ class StorageDaemon : public td::actor::Actor {
}
auto r_conf_data = td::read_file(global_config_);
r_conf_data.ensure();
std::string key_store = db_root_ + "/tonlib/";
td::mkpath(key_store).ensure();
auto tonlib_options = tonlib_api::make_object<tonlib_api::options>(
tonlib_api::make_object<tonlib_api::config>(r_conf_data.move_as_ok().as_slice().str(), "", false, false),
tonlib_api::make_object<tonlib_api::keyStoreTypeInMemory>());
tonlib_api::make_object<tonlib_api::keyStoreTypeDirectory>(key_store));
tonlib_client_ = td::actor::create_actor<tonlib::TonlibClientWrapper>("tonlibclient", std::move(tonlib_options));
}

Expand Down

0 comments on commit 92f8ded

Please sign in to comment.