Skip to content

Commit

Permalink
Reinit
Browse files Browse the repository at this point in the history
  • Loading branch information
tvorogme committed Feb 14, 2024
1 parent 019dee6 commit f90056f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
9 changes: 4 additions & 5 deletions validator/db/celldb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ void CellDbIn::start_up() {
boc_->set_celldb_compress_depth(opts_->get_celldb_compress_depth());
boc_->set_loader(std::make_unique<vm::CellLoader>(cell_db_->snapshot(), on_load_callback_)).ensure();
td::actor::send_closure(parent_, &CellDb::update_snapshot, cell_db_->snapshot());
last_catch_timeout_ = td::Timestamp::at(0.1);
alarm_timestamp() = td::Timestamp::in(10.0);

auto empty = get_empty_key_hash();
Expand All @@ -105,10 +104,6 @@ void CellDbIn::start_up() {
}

void CellDbIn::load_cell(RootHash hash, td::Promise<td::Ref<vm::DataCell>> promise) {
if (read_only_ && last_catch_timeout_.is_in_past()) {
td::actor::send_closure(parent_, &CellDb::update_snapshot, cell_db_->snapshot());
last_catch_timeout_ = td::Timestamp::at(0.1);
}
boc_->load_cell_async(hash.as_slice(), async_executor, std::move(promise));
}

Expand Down Expand Up @@ -202,6 +197,10 @@ void CellDbIn::alarm() {
td::actor::send_closure(root_db_, &RootDb::allow_state_gc, block_id, std::move(P));
}

void CellDbIn::reinit() {
td::actor::send_closure(parent_, &CellDb::update_snapshot, cell_db_->snapshot());
}

void CellDbIn::gc(BlockIdExt block_id) {
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<BlockHandle> R) {
R.ensure();
Expand Down
14 changes: 10 additions & 4 deletions validator/db/celldb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class CellDbAsyncExecutor;
class CellDbBase : public td::actor::Actor {
public:
virtual void start_up();

protected:
std::shared_ptr<vm::DynamicBagOfCellsDb::AsyncExecutor> async_executor;

private:
void execute_sync(std::function<void()> f);
friend CellDbAsyncExecutor;
Expand All @@ -57,10 +59,11 @@ class CellDbIn : public CellDbBase {
void migrate_cell(td::Bits256 hash);

CellDbIn(td::actor::ActorId<RootDb> root_db, td::actor::ActorId<CellDb> parent, std::string path,
td::Ref<ValidatorManagerOptions> opts, bool read_only=false);
td::Ref<ValidatorManagerOptions> opts, bool read_only = false);

void start_up() override;
void alarm() override;
void reinit();

private:
struct DbEntry {
Expand Down Expand Up @@ -97,7 +100,6 @@ class CellDbIn : public CellDbBase {

td::actor::ActorId<RootDb> root_db_;
td::actor::ActorId<CellDb> parent_;
td::Timestamp last_catch_timeout_;

std::string path_;
td::Ref<ValidatorManagerOptions> opts_;
Expand Down Expand Up @@ -145,11 +147,15 @@ class CellDb : public CellDbBase {
}
void get_cell_db_reader(td::Promise<std::shared_ptr<vm::CellDbReader>> promise);

CellDb(td::actor::ActorId<RootDb> root_db, std::string path, td::Ref<ValidatorManagerOptions> opts, bool read_only=false)
: root_db_(root_db), path_(path), opts_(opts), read_only_(read_only) {
CellDb(td::actor::ActorId<RootDb> root_db, std::string path, td::Ref<ValidatorManagerOptions> opts,
bool read_only = false)
: root_db_(root_db), path_(path), opts_(opts), read_only_(read_only) {
}

void start_up() override;
void reinit() {
td::actor::send_closure(cell_db_, &CellDbIn::reinit);
}

private:
td::actor::ActorId<RootDb> root_db_;
Expand Down
1 change: 1 addition & 0 deletions validator/db/rootdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ void RootDb::run_gc(UnixTime mc_ts, UnixTime gc_ts, UnixTime archive_ttl) {

void RootDb::reinit() {
td::actor::send_closure(archive_db_, &ArchiveManager::reinit);
td::actor::send_closure(cell_db_, &CellDb::reinit);
}

} // namespace validator
Expand Down
2 changes: 2 additions & 0 deletions validator/manager-disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,7 @@ void ValidatorManagerImpl::receiveLastBlock(td::Result<td::Ref<BlockData>> block
td::actor::send_closure(db_, &Db::reinit);
LOG(INFO) << "New MC block: " << last_masterchain_block_id_
<< " at: " << time_to_human(last_masterchain_time_) + ", shards: " << shards_idents;
td::actor::send_closure(actor_id(this), &ValidatorManagerImpl::reinit);

// Handle wait_block
while (!shard_client_waiters_.empty()) {
Expand Down Expand Up @@ -1402,6 +1403,7 @@ void ValidatorManagerImpl::update_shard_client_state(BlockIdExt masterchain_bloc
void ValidatorManagerImpl::update_lite_server_state(BlockIdExt shard_client, td::Ref<MasterchainState> state) {
if (last_liteserver_state_.is_null()) {
LOG(INFO) << "New shard client available (from null): " << shard_client;
td::actor::send_closure(actor_id(this), &ValidatorManagerImpl::reinit);
last_liteserver_block_id_ = shard_client;
last_liteserver_state_ = std::move(state);
return;
Expand Down

0 comments on commit f90056f

Please sign in to comment.