Skip to content

Commit 5d27d05

Browse files
committed
Optimize reading files in BlockArchiver
1 parent e376747 commit 5d27d05

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

validator/db/archive-manager.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,11 @@ void ArchiveManager::get_key_block_proof(FileReference ref_id, td::Promise<td::B
262262
}
263263

264264
void ArchiveManager::get_temp_file_short(FileReference ref_id, td::Promise<td::BufferSlice> promise) {
265-
get_file_short_cont(std::move(ref_id), get_max_temp_file_desc_idx(), std::move(promise));
265+
get_temp_file_short_cont(std::move(ref_id), get_max_temp_file_desc_idx(), std::move(promise));
266266
}
267267

268-
void ArchiveManager::get_file_short_cont(FileReference ref_id, PackageId idx, td::Promise<td::BufferSlice> promise) {
268+
void ArchiveManager::get_temp_file_short_cont(FileReference ref_id, PackageId idx,
269+
td::Promise<td::BufferSlice> promise) {
269270
auto f = get_temp_file_desc_by_idx(idx);
270271
if (!f) {
271272
promise.set_error(td::Status::Error(ErrorCode::notready, "file not in db"));
@@ -276,7 +277,8 @@ void ArchiveManager::get_file_short_cont(FileReference ref_id, PackageId idx, td
276277
if (R.is_ok()) {
277278
promise.set_value(R.move_as_ok());
278279
} else {
279-
td::actor::send_closure(SelfId, &ArchiveManager::get_file_short_cont, std::move(ref_id), idx, std::move(promise));
280+
td::actor::send_closure(SelfId, &ArchiveManager::get_temp_file_short_cont, std::move(ref_id), idx,
281+
std::move(promise));
280282
}
281283
});
282284
td::actor::send_closure(f->file_actor_id(), &ArchiveSlice::get_file, nullptr, std::move(ref_id), std::move(P));
@@ -294,20 +296,18 @@ void ArchiveManager::get_file(ConstBlockHandle handle, FileReference ref_id, td:
294296
if (handle->handle_moved_to_archive()) {
295297
auto f = get_file_desc(handle->id().shard_full(), get_package_id(handle->masterchain_ref_block()), 0, 0, 0, false);
296298
if (f) {
297-
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), ref_id, idx = get_max_temp_file_desc_idx(),
298-
promise = std::move(promise)](td::Result<td::BufferSlice> R) mutable {
299+
promise = [=, promise = std::move(promise),
300+
file_actor = f->file_actor_id()](td::Result<td::BufferSlice> R) mutable {
299301
if (R.is_ok()) {
300302
promise.set_value(R.move_as_ok());
301-
} else {
302-
td::actor::send_closure(SelfId, &ArchiveManager::get_file_short_cont, ref_id, idx, std::move(promise));
303+
return;
303304
}
304-
});
305-
td::actor::send_closure(f->file_actor_id(), &ArchiveSlice::get_file, std::move(handle), std::move(ref_id),
306-
std::move(P));
307-
return;
305+
td::actor::send_closure(file_actor, &ArchiveSlice::get_file, std::move(handle), std::move(ref_id),
306+
std::move(promise));
307+
};
308308
}
309309
}
310-
get_file_short_cont(std::move(ref_id), get_max_temp_file_desc_idx(), std::move(promise));
310+
get_temp_file_short(std::move(ref_id), std::move(promise));
311311
}
312312

313313
void ArchiveManager::register_perm_state(FileReferenceShort id) {

validator/db/archive-manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class ArchiveManager : public td::actor::Actor {
204204
void deleted_package(PackageId seqno, td::Promise<td::Unit> promise);
205205
void get_handle_cont(BlockIdExt block_id, PackageId id, td::Promise<BlockHandle> promise);
206206
void get_handle_finish(BlockHandle handle, td::Promise<BlockHandle> promise);
207-
void get_file_short_cont(FileReference ref_id, PackageId idx, td::Promise<td::BufferSlice> promise);
207+
void get_temp_file_short_cont(FileReference ref_id, PackageId idx, td::Promise<td::BufferSlice> promise);
208208

209209
const FileDescription *get_file_desc(ShardIdFull shard, PackageId id, BlockSeqno seqno, UnixTime ts, LogicalTime lt,
210210
bool force);

0 commit comments

Comments
 (0)