mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Improve handling of absent blocks in archive manager (#600)
This commit is contained in:
parent
c6143715cc
commit
45c0270716
1 changed files with 30 additions and 11 deletions
|
@ -749,6 +749,9 @@ ArchiveManager::FileDescription *ArchiveManager::get_file_desc_by_seqno(AccountI
|
||||||
return get_file_desc_by_seqno(ShardIdFull{masterchainId}, seqno, key_block);
|
return get_file_desc_by_seqno(ShardIdFull{masterchainId}, seqno, key_block);
|
||||||
}
|
}
|
||||||
for (auto it = f.rbegin(); it != f.rend(); it++) {
|
for (auto it = f.rbegin(); it != f.rend(); it++) {
|
||||||
|
if (it->second.deleted) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int i = 0; i < 60; i++) {
|
for (int i = 0; i < 60; i++) {
|
||||||
auto shard = shard_prefix(account, i);
|
auto shard = shard_prefix(account, i);
|
||||||
|
@ -773,6 +776,9 @@ ArchiveManager::FileDescription *ArchiveManager::get_file_desc_by_unix_time(Acco
|
||||||
return get_file_desc_by_unix_time(ShardIdFull{masterchainId}, ts, key_block);
|
return get_file_desc_by_unix_time(ShardIdFull{masterchainId}, ts, key_block);
|
||||||
}
|
}
|
||||||
for (auto it = f.rbegin(); it != f.rend(); it++) {
|
for (auto it = f.rbegin(); it != f.rend(); it++) {
|
||||||
|
if (it->second.deleted) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int i = 0; i < 60; i++) {
|
for (int i = 0; i < 60; i++) {
|
||||||
auto shard = shard_prefix(account, i);
|
auto shard = shard_prefix(account, i);
|
||||||
|
@ -797,6 +803,9 @@ ArchiveManager::FileDescription *ArchiveManager::get_file_desc_by_lt(AccountIdPr
|
||||||
return get_file_desc_by_lt(ShardIdFull{masterchainId}, lt, key_block);
|
return get_file_desc_by_lt(ShardIdFull{masterchainId}, lt, key_block);
|
||||||
}
|
}
|
||||||
for (auto it = f.rbegin(); it != f.rend(); it++) {
|
for (auto it = f.rbegin(); it != f.rend(); it++) {
|
||||||
|
if (it->second.deleted) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int i = 0; i < 60; i++) {
|
for (int i = 0; i < 60; i++) {
|
||||||
auto shard = shard_prefix(account, i);
|
auto shard = shard_prefix(account, i);
|
||||||
|
@ -818,13 +827,15 @@ ArchiveManager::FileDescription *ArchiveManager::get_next_file_desc(FileDescript
|
||||||
auto &m = get_file_map(f->id);
|
auto &m = get_file_map(f->id);
|
||||||
auto it = m.find(f->id);
|
auto it = m.find(f->id);
|
||||||
CHECK(it != m.end());
|
CHECK(it != m.end());
|
||||||
|
while (true) {
|
||||||
it++;
|
it++;
|
||||||
if (it == m.end()) {
|
if (it == m.end()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else if (!it->second.deleted) {
|
||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ArchiveManager::FileDescription *ArchiveManager::get_temp_file_desc_by_idx(PackageId idx) {
|
ArchiveManager::FileDescription *ArchiveManager::get_temp_file_desc_by_idx(PackageId idx) {
|
||||||
auto it = temp_files_.find(idx);
|
auto it = temp_files_.find(idx);
|
||||||
|
@ -1159,13 +1170,17 @@ void ArchiveManager::truncate(BlockSeqno masterchain_seqno, ConstBlockHandle han
|
||||||
auto it = key_files_.begin();
|
auto it = key_files_.begin();
|
||||||
while (it != key_files_.end()) {
|
while (it != key_files_.end()) {
|
||||||
if (it->first.id <= masterchain_seqno) {
|
if (it->first.id <= masterchain_seqno) {
|
||||||
|
if (!it->second.deleted) {
|
||||||
td::actor::send_closure(it->second.file_actor_id(), &ArchiveSlice::truncate, masterchain_seqno, handle,
|
td::actor::send_closure(it->second.file_actor_id(), &ArchiveSlice::truncate, masterchain_seqno, handle,
|
||||||
ig.get_promise());
|
ig.get_promise());
|
||||||
|
}
|
||||||
it++;
|
it++;
|
||||||
} else {
|
} else {
|
||||||
auto it2 = it;
|
auto it2 = it;
|
||||||
it++;
|
it++;
|
||||||
|
if (!it2->second.deleted) {
|
||||||
td::actor::send_closure(it2->second.file_actor_id(), &ArchiveSlice::destroy, ig.get_promise());
|
td::actor::send_closure(it2->second.file_actor_id(), &ArchiveSlice::destroy, ig.get_promise());
|
||||||
|
}
|
||||||
it2->second.file.release();
|
it2->second.file.release();
|
||||||
index_
|
index_
|
||||||
->erase(create_serialize_tl_object<ton_api::db_files_package_key>(it2->second.id.id, it2->second.id.key,
|
->erase(create_serialize_tl_object<ton_api::db_files_package_key>(it2->second.id.id, it2->second.id.key,
|
||||||
|
@ -1180,13 +1195,17 @@ void ArchiveManager::truncate(BlockSeqno masterchain_seqno, ConstBlockHandle han
|
||||||
auto it = files_.begin();
|
auto it = files_.begin();
|
||||||
while (it != files_.end()) {
|
while (it != files_.end()) {
|
||||||
if (it->first.id <= masterchain_seqno) {
|
if (it->first.id <= masterchain_seqno) {
|
||||||
|
if (!it->second.deleted) {
|
||||||
td::actor::send_closure(it->second.file_actor_id(), &ArchiveSlice::truncate, masterchain_seqno, handle,
|
td::actor::send_closure(it->second.file_actor_id(), &ArchiveSlice::truncate, masterchain_seqno, handle,
|
||||||
ig.get_promise());
|
ig.get_promise());
|
||||||
|
}
|
||||||
it++;
|
it++;
|
||||||
} else {
|
} else {
|
||||||
auto it2 = it;
|
auto it2 = it;
|
||||||
it++;
|
it++;
|
||||||
|
if (!it2->second.deleted) {
|
||||||
td::actor::send_closure(it2->second.file_actor_id(), &ArchiveSlice::destroy, ig.get_promise());
|
td::actor::send_closure(it2->second.file_actor_id(), &ArchiveSlice::destroy, ig.get_promise());
|
||||||
|
}
|
||||||
it2->second.file.release();
|
it2->second.file.release();
|
||||||
index_
|
index_
|
||||||
->erase(create_serialize_tl_object<ton_api::db_files_package_key>(it2->second.id.id, it2->second.id.key,
|
->erase(create_serialize_tl_object<ton_api::db_files_package_key>(it2->second.id.id, it2->second.id.key,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue