mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
speed up synchronization
- download old files in chunks - updated docs - fixed elector/config smartcontracts
This commit is contained in:
parent
0dae2c157b
commit
7f3a22a217
21 changed files with 365 additions and 191 deletions
|
@ -40,11 +40,9 @@ void ShardClient::start_up() {
|
|||
}
|
||||
|
||||
void ShardClient::start() {
|
||||
if (!started_ && masterchain_state_.not_null()) {
|
||||
started_ = true;
|
||||
apply_all_shards();
|
||||
} else {
|
||||
if (!started_) {
|
||||
started_ = true;
|
||||
saved_to_db();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +50,31 @@ void ShardClient::got_state_from_db(BlockIdExt state) {
|
|||
CHECK(!init_mode_);
|
||||
|
||||
CHECK(state.is_valid());
|
||||
new_masterchain_block_id(state);
|
||||
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<BlockHandle> R) {
|
||||
R.ensure();
|
||||
td::actor::send_closure(SelfId, &ShardClient::got_init_handle_from_db, R.move_as_ok());
|
||||
});
|
||||
td::actor::send_closure(manager_, &ValidatorManager::get_block_handle, state, true, std::move(P));
|
||||
}
|
||||
|
||||
void ShardClient::got_init_handle_from_db(BlockHandle handle) {
|
||||
masterchain_block_handle_ = std::move(handle);
|
||||
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<td::Ref<ShardState>> R) {
|
||||
R.ensure();
|
||||
td::actor::send_closure(SelfId, &ShardClient::got_init_state_from_db, td::Ref<MasterchainState>{R.move_as_ok()});
|
||||
});
|
||||
td::actor::send_closure(manager_, &ValidatorManager::get_shard_state_from_db, masterchain_block_handle_,
|
||||
std::move(P));
|
||||
}
|
||||
|
||||
void ShardClient::got_init_state_from_db(td::Ref<MasterchainState> state) {
|
||||
masterchain_state_ = std::move(state);
|
||||
build_shard_overlays();
|
||||
masterchain_state_.clear();
|
||||
|
||||
saved_to_db();
|
||||
}
|
||||
|
||||
void ShardClient::start_up_init_mode() {
|
||||
|
@ -97,14 +119,19 @@ void ShardClient::applied_all_shards() {
|
|||
}
|
||||
|
||||
void ShardClient::saved_to_db() {
|
||||
if (init_mode_) {
|
||||
promise_.set_value(td::Unit());
|
||||
init_mode_ = false;
|
||||
}
|
||||
|
||||
CHECK(masterchain_block_handle_);
|
||||
td::actor::send_closure(manager_, &ValidatorManager::update_shard_client_block_handle, masterchain_block_handle_,
|
||||
[](td::Unit) {});
|
||||
if (promise_) {
|
||||
promise_.set_value(td::Unit());
|
||||
}
|
||||
if (init_mode_) {
|
||||
init_mode_ = false;
|
||||
}
|
||||
|
||||
if (!started_) {
|
||||
return;
|
||||
}
|
||||
if (masterchain_block_handle_->inited_next_left()) {
|
||||
new_masterchain_block_id(masterchain_block_handle_->one_next(true));
|
||||
} else {
|
||||
|
@ -239,6 +266,40 @@ void ShardClient::build_shard_overlays() {
|
|||
}
|
||||
}
|
||||
|
||||
void ShardClient::force_update_shard_client(BlockHandle handle, td::Promise<td::Unit> promise) {
|
||||
CHECK(!init_mode_);
|
||||
CHECK(!started_);
|
||||
|
||||
if (masterchain_block_handle_->id().seqno() >= handle->id().seqno()) {
|
||||
promise.set_value(td::Unit());
|
||||
return;
|
||||
}
|
||||
|
||||
auto P = td::PromiseCreator::lambda(
|
||||
[SelfId = actor_id(this), handle, promise = std::move(promise)](td::Result<td::Ref<ShardState>> R) mutable {
|
||||
R.ensure();
|
||||
td::actor::send_closure(SelfId, &ShardClient::force_update_shard_client_ex, std::move(handle),
|
||||
td::Ref<MasterchainState>{R.move_as_ok()}, std::move(promise));
|
||||
});
|
||||
td::actor::send_closure(manager_, &ValidatorManager::get_shard_state_from_db, std::move(handle), std::move(P));
|
||||
}
|
||||
|
||||
void ShardClient::force_update_shard_client_ex(BlockHandle handle, td::Ref<MasterchainState> state,
|
||||
td::Promise<td::Unit> promise) {
|
||||
CHECK(!init_mode_);
|
||||
CHECK(!started_);
|
||||
|
||||
if (masterchain_block_handle_->id().seqno() >= handle->id().seqno()) {
|
||||
promise.set_value(td::Unit());
|
||||
return;
|
||||
}
|
||||
masterchain_block_handle_ = std::move(handle);
|
||||
masterchain_state_ = std::move(state);
|
||||
promise_ = std::move(promise);
|
||||
build_shard_overlays();
|
||||
applied_all_shards();
|
||||
}
|
||||
|
||||
} // namespace validator
|
||||
|
||||
} // namespace ton
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue