mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
slightly changed block format
- small change in block format - added config in blockchain explorer - bugfixes
This commit is contained in:
parent
7f3a22a217
commit
090e0c16eb
82 changed files with 1852 additions and 391 deletions
|
@ -45,9 +45,11 @@ void ArchiveManager::add_handle(BlockHandle handle, td::Promise<td::Unit> promis
|
|||
update_handle(std::move(handle), std::move(promise));
|
||||
return;
|
||||
}
|
||||
auto p = get_package_id_force(handle->masterchain_ref_block(), handle->id().shard_full(), handle->id().seqno(),
|
||||
handle->unix_time(), handle->logical_time(),
|
||||
handle->inited_is_key_block() && handle->is_key_block());
|
||||
auto p = handle->id().is_masterchain()
|
||||
? get_package_id_force(handle->masterchain_ref_block(), handle->id().shard_full(), handle->id().seqno(),
|
||||
handle->unix_time(), handle->logical_time(),
|
||||
handle->inited_is_key_block() && handle->is_key_block())
|
||||
: get_package_id(handle->masterchain_ref_block());
|
||||
auto f = get_file_desc(handle->id().shard_full(), p, handle->id().seqno(), handle->unix_time(),
|
||||
handle->logical_time(), true);
|
||||
td::actor::send_closure(f->file_actor_id(), &ArchiveSlice::add_handle, std::move(handle), std::move(promise));
|
||||
|
@ -248,7 +250,7 @@ void ArchiveManager::get_file_short_cont(FileReference ref_id, PackageId idx, td
|
|||
td::actor::send_closure(f->file_actor_id(), &ArchiveSlice::get_file, std::move(ref_id), std::move(P));
|
||||
}
|
||||
|
||||
void ArchiveManager::get_file(BlockHandle handle, FileReference ref_id, td::Promise<td::BufferSlice> promise) {
|
||||
void ArchiveManager::get_file(ConstBlockHandle handle, FileReference ref_id, td::Promise<td::BufferSlice> promise) {
|
||||
if (handle->moved_to_archive()) {
|
||||
auto f = get_file_desc(handle->id().shard_full(), get_package_id(handle->masterchain_ref_block()), 0, 0, 0, false);
|
||||
if (f) {
|
||||
|
@ -368,27 +370,53 @@ void ArchiveManager::check_persistent_state(BlockIdExt block_id, BlockIdExt mast
|
|||
}
|
||||
|
||||
void ArchiveManager::get_block_by_unix_time(AccountIdPrefixFull account_id, UnixTime ts,
|
||||
td::Promise<BlockHandle> promise) {
|
||||
td::Promise<ConstBlockHandle> promise) {
|
||||
auto f = get_file_desc_by_unix_time(account_id, ts, false);
|
||||
if (f) {
|
||||
td::actor::send_closure(f->file_actor_id(), &ArchiveSlice::get_block_by_unix_time, account_id, ts,
|
||||
std::move(promise));
|
||||
auto n = get_next_file_desc(f);
|
||||
td::actor::ActorId<ArchiveSlice> aid;
|
||||
if (n) {
|
||||
aid = n->file_actor_id();
|
||||
}
|
||||
auto P = td::PromiseCreator::lambda(
|
||||
[aid, account_id, ts, promise = std::move(promise)](td::Result<ConstBlockHandle> R) mutable {
|
||||
if (R.is_ok() || R.error().code() != ErrorCode::notready || aid.empty()) {
|
||||
promise.set_result(std::move(R));
|
||||
} else {
|
||||
td::actor::send_closure(aid, &ArchiveSlice::get_block_by_unix_time, account_id, ts, std::move(promise));
|
||||
}
|
||||
});
|
||||
td::actor::send_closure(f->file_actor_id(), &ArchiveSlice::get_block_by_unix_time, account_id, ts, std::move(P));
|
||||
} else {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "ts not in db"));
|
||||
}
|
||||
}
|
||||
|
||||
void ArchiveManager::get_block_by_lt(AccountIdPrefixFull account_id, LogicalTime lt, td::Promise<BlockHandle> promise) {
|
||||
void ArchiveManager::get_block_by_lt(AccountIdPrefixFull account_id, LogicalTime lt,
|
||||
td::Promise<ConstBlockHandle> promise) {
|
||||
auto f = get_file_desc_by_lt(account_id, lt, false);
|
||||
if (f) {
|
||||
td::actor::send_closure(f->file_actor_id(), &ArchiveSlice::get_block_by_lt, account_id, lt, std::move(promise));
|
||||
auto n = get_next_file_desc(f);
|
||||
td::actor::ActorId<ArchiveSlice> aid;
|
||||
if (n) {
|
||||
aid = n->file_actor_id();
|
||||
}
|
||||
auto P = td::PromiseCreator::lambda(
|
||||
[aid, account_id, lt, promise = std::move(promise)](td::Result<ConstBlockHandle> R) mutable {
|
||||
if (R.is_ok() || R.error().code() != ErrorCode::notready || aid.empty()) {
|
||||
promise.set_result(std::move(R));
|
||||
} else {
|
||||
td::actor::send_closure(aid, &ArchiveSlice::get_block_by_lt, account_id, lt, std::move(promise));
|
||||
}
|
||||
});
|
||||
td::actor::send_closure(f->file_actor_id(), &ArchiveSlice::get_block_by_lt, account_id, lt, std::move(P));
|
||||
} else {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "lt not in db"));
|
||||
}
|
||||
}
|
||||
|
||||
void ArchiveManager::get_block_by_seqno(AccountIdPrefixFull account_id, BlockSeqno seqno,
|
||||
td::Promise<BlockHandle> promise) {
|
||||
td::Promise<ConstBlockHandle> promise) {
|
||||
auto f = get_file_desc_by_seqno(account_id, seqno, false);
|
||||
if (f) {
|
||||
td::actor::send_closure(f->file_actor_id(), &ArchiveSlice::get_block_by_seqno, account_id, seqno,
|
||||
|
@ -398,7 +426,7 @@ void ArchiveManager::get_block_by_seqno(AccountIdPrefixFull account_id, BlockSeq
|
|||
}
|
||||
}
|
||||
|
||||
void ArchiveManager::delete_package(PackageId id) {
|
||||
void ArchiveManager::delete_package(PackageId id, td::Promise<td::Unit> promise) {
|
||||
auto key = create_serialize_tl_object<ton_api::db_files_package_key>(id.id, id.key, id.temp);
|
||||
|
||||
std::string value;
|
||||
|
@ -411,24 +439,27 @@ void ArchiveManager::delete_package(PackageId id) {
|
|||
auto x = R.move_as_ok();
|
||||
|
||||
if (x->deleted_) {
|
||||
promise.set_value(td::Unit());
|
||||
return;
|
||||
}
|
||||
|
||||
auto &m = get_file_map(id);
|
||||
auto it = m.find(id);
|
||||
if (it == m.end() || it->second.deleted) {
|
||||
promise.set_value(td::Unit());
|
||||
return;
|
||||
}
|
||||
|
||||
it->second.deleted = true;
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), id](td::Result<td::Unit> R) {
|
||||
R.ensure();
|
||||
td::actor::send_closure(SelfId, &ArchiveManager::deleted_package, id);
|
||||
});
|
||||
auto P = td::PromiseCreator::lambda(
|
||||
[SelfId = actor_id(this), id, promise = std::move(promise)](td::Result<td::Unit> R) mutable {
|
||||
R.ensure();
|
||||
td::actor::send_closure(SelfId, &ArchiveManager::deleted_package, id, std::move(promise));
|
||||
});
|
||||
td::actor::send_closure(it->second.file_actor_id(), &ArchiveSlice::destroy, std::move(P));
|
||||
}
|
||||
|
||||
void ArchiveManager::deleted_package(PackageId id) {
|
||||
void ArchiveManager::deleted_package(PackageId id, td::Promise<td::Unit> promise) {
|
||||
auto key = create_serialize_tl_object<ton_api::db_files_package_key>(id.id, id.key, id.temp);
|
||||
|
||||
std::string value;
|
||||
|
@ -441,6 +472,7 @@ void ArchiveManager::deleted_package(PackageId id) {
|
|||
auto x = R.move_as_ok();
|
||||
|
||||
if (x->deleted_) {
|
||||
promise.set_value(td::Unit());
|
||||
return;
|
||||
}
|
||||
x->deleted_ = true;
|
||||
|
@ -453,6 +485,7 @@ void ArchiveManager::deleted_package(PackageId id) {
|
|||
CHECK(it != m.end());
|
||||
CHECK(it->second.deleted);
|
||||
it->second.clear_actor_id();
|
||||
promise.set_value(td::Unit());
|
||||
}
|
||||
|
||||
void ArchiveManager::load_package(PackageId id) {
|
||||
|
@ -690,6 +723,18 @@ ArchiveManager::FileDescription *ArchiveManager::get_file_desc_by_lt(AccountIdPr
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ArchiveManager::FileDescription *ArchiveManager::get_next_file_desc(FileDescription *f) {
|
||||
auto &m = get_file_map(f->id);
|
||||
auto it = m.find(f->id);
|
||||
CHECK(it != m.end());
|
||||
it++;
|
||||
if (it == m.end()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return &it->second;
|
||||
}
|
||||
}
|
||||
|
||||
ArchiveManager::FileDescription *ArchiveManager::get_temp_file_desc_by_idx(PackageId idx) {
|
||||
auto it = temp_files_.find(idx);
|
||||
if (it != temp_files_.end()) {
|
||||
|
@ -797,7 +842,7 @@ void ArchiveManager::run_gc(UnixTime ts) {
|
|||
vec.resize(vec.size() - 1, PackageId::empty(false, true));
|
||||
|
||||
for (auto &x : vec) {
|
||||
delete_package(x);
|
||||
delete_package(x, [](td::Unit) {});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -841,7 +886,7 @@ void ArchiveManager::persistent_state_gc(FileHash last) {
|
|||
return;
|
||||
}
|
||||
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), hash](td::Result<BlockHandle> R) {
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), hash](td::Result<ConstBlockHandle> R) {
|
||||
if (R.is_error()) {
|
||||
td::actor::send_closure(SelfId, &ArchiveManager::got_gc_masterchain_handle, nullptr, hash);
|
||||
} else {
|
||||
|
@ -852,7 +897,7 @@ void ArchiveManager::persistent_state_gc(FileHash last) {
|
|||
get_block_by_seqno(AccountIdPrefixFull{masterchainId, 0}, seqno, std::move(P));
|
||||
}
|
||||
|
||||
void ArchiveManager::got_gc_masterchain_handle(BlockHandle handle, FileHash hash) {
|
||||
void ArchiveManager::got_gc_masterchain_handle(ConstBlockHandle handle, FileHash hash) {
|
||||
bool to_del = false;
|
||||
if (!handle || !handle->inited_unix_time() || !handle->unix_time()) {
|
||||
to_del = true;
|
||||
|
@ -881,7 +926,7 @@ PackageId ArchiveManager::get_temp_package_id_by_unixtime(UnixTime ts) const {
|
|||
}
|
||||
|
||||
PackageId ArchiveManager::get_key_package_id(BlockSeqno seqno) const {
|
||||
return PackageId{seqno - seqno % 200000, true, false};
|
||||
return PackageId{seqno - seqno % key_archive_size(), true, false};
|
||||
}
|
||||
|
||||
PackageId ArchiveManager::get_package_id(BlockSeqno seqno) const {
|
||||
|
@ -896,7 +941,7 @@ PackageId ArchiveManager::get_package_id_force(BlockSeqno masterchain_seqno, Sha
|
|||
PackageId p = PackageId::empty(false, false);
|
||||
if (!is_key) {
|
||||
auto it = files_.upper_bound(PackageId{masterchain_seqno, false, false});
|
||||
p = PackageId{masterchain_seqno - (masterchain_seqno % 20000), false, false};
|
||||
p = PackageId{masterchain_seqno - (masterchain_seqno % archive_size()), false, false};
|
||||
if (it != files_.begin()) {
|
||||
it--;
|
||||
if (p < it->first) {
|
||||
|
@ -980,6 +1025,7 @@ void ArchiveManager::set_async_mode(bool mode, td::Promise<td::Unit> promise) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace validator
|
||||
|
||||
} // namespace ton
|
||||
|
|
|
@ -48,7 +48,7 @@ class ArchiveManager : public td::actor::Actor {
|
|||
void get_key_block_proof(FileReference ref_id, td::Promise<td::BufferSlice> promise);
|
||||
void get_temp_file_short(FileReference ref_id, td::Promise<td::BufferSlice> promise);
|
||||
void get_file_short(FileReference ref_id, td::Promise<td::BufferSlice> promise);
|
||||
void get_file(BlockHandle handle, FileReference ref_id, td::Promise<td::BufferSlice> promise);
|
||||
void get_file(ConstBlockHandle handle, FileReference ref_id, td::Promise<td::BufferSlice> promise);
|
||||
|
||||
void add_zero_state(BlockIdExt block_id, td::BufferSlice data, td::Promise<td::Unit> promise);
|
||||
void add_persistent_state(BlockIdExt block_id, BlockIdExt masterchain_block_id, td::BufferSlice data,
|
||||
|
@ -60,12 +60,15 @@ class ArchiveManager : public td::actor::Actor {
|
|||
void check_persistent_state(BlockIdExt block_id, BlockIdExt masterchain_block_id, td::Promise<bool> promise);
|
||||
void check_zero_state(BlockIdExt block_id, td::Promise<bool> promise);
|
||||
|
||||
//void truncate(BlockSeqno masterchain_seqno, td::Promise<td::Unit> promise);
|
||||
//void truncate_continue(BlockSeqno masterchain_seqno, td::Promise<td::Unit> promise);
|
||||
|
||||
void run_gc(UnixTime ts);
|
||||
|
||||
/* from LTDB */
|
||||
void get_block_by_unix_time(AccountIdPrefixFull account_id, UnixTime ts, td::Promise<BlockHandle> promise);
|
||||
void get_block_by_lt(AccountIdPrefixFull account_id, LogicalTime lt, td::Promise<BlockHandle> promise);
|
||||
void get_block_by_seqno(AccountIdPrefixFull account_id, BlockSeqno seqno, td::Promise<BlockHandle> promise);
|
||||
void get_block_by_unix_time(AccountIdPrefixFull account_id, UnixTime ts, td::Promise<ConstBlockHandle> promise);
|
||||
void get_block_by_lt(AccountIdPrefixFull account_id, LogicalTime lt, td::Promise<ConstBlockHandle> promise);
|
||||
void get_block_by_seqno(AccountIdPrefixFull account_id, BlockSeqno seqno, td::Promise<ConstBlockHandle> promise);
|
||||
|
||||
void get_archive_id(BlockSeqno masterchain_seqno, td::Promise<td::uint64> promise);
|
||||
void get_archive_slice(td::uint64 archive_id, td::uint64 offset, td::uint32 limit,
|
||||
|
@ -77,6 +80,13 @@ class ArchiveManager : public td::actor::Actor {
|
|||
void commit_transaction();
|
||||
void set_async_mode(bool mode, td::Promise<td::Unit> promise);
|
||||
|
||||
static constexpr td::uint32 archive_size() {
|
||||
return 20000;
|
||||
}
|
||||
static constexpr td::uint32 key_archive_size() {
|
||||
return 200000;
|
||||
}
|
||||
|
||||
private:
|
||||
struct FileDescription {
|
||||
struct Desc {
|
||||
|
@ -113,8 +123,8 @@ class ArchiveManager : public td::actor::Actor {
|
|||
std::map<FileHash, FileReferenceShort> perm_states_;
|
||||
|
||||
void load_package(PackageId seqno);
|
||||
void delete_package(PackageId seqno);
|
||||
void deleted_package(PackageId seqno);
|
||||
void delete_package(PackageId seqno, td::Promise<td::Unit> promise);
|
||||
void deleted_package(PackageId seqno, td::Promise<td::Unit> promise);
|
||||
void get_handle_cont(BlockIdExt block_id, PackageId id, td::Promise<BlockHandle> promise);
|
||||
void get_handle_finish(BlockHandle handle, td::Promise<BlockHandle> promise);
|
||||
void get_file_short_cont(FileReference ref_id, PackageId idx, td::Promise<td::BufferSlice> promise);
|
||||
|
@ -129,6 +139,7 @@ class ArchiveManager : public td::actor::Actor {
|
|||
FileDescription *get_file_desc_by_seqno(AccountIdPrefixFull shard, BlockSeqno seqno, bool key_block);
|
||||
FileDescription *get_file_desc_by_lt(AccountIdPrefixFull shard, LogicalTime lt, bool key_block);
|
||||
FileDescription *get_file_desc_by_unix_time(AccountIdPrefixFull shard, UnixTime ts, bool key_block);
|
||||
FileDescription *get_next_file_desc(FileDescription *f);
|
||||
FileDescription *get_temp_file_desc_by_idx(PackageId idx);
|
||||
PackageId get_max_temp_file_desc_idx();
|
||||
PackageId get_prev_temp_file_desc_idx(PackageId id);
|
||||
|
@ -136,7 +147,7 @@ class ArchiveManager : public td::actor::Actor {
|
|||
void written_perm_state(FileReferenceShort id);
|
||||
|
||||
void persistent_state_gc(FileHash last);
|
||||
void got_gc_masterchain_handle(BlockHandle handle, FileHash hash);
|
||||
void got_gc_masterchain_handle(ConstBlockHandle handle, FileHash hash);
|
||||
|
||||
std::string db_root_;
|
||||
|
||||
|
|
|
@ -204,6 +204,28 @@ void ArchiveSlice::get_handle(BlockIdExt block_id, td::Promise<BlockHandle> prom
|
|||
promise.set_value(std::move(handle));
|
||||
}
|
||||
|
||||
void ArchiveSlice::get_temp_handle(BlockIdExt block_id, td::Promise<ConstBlockHandle> promise) {
|
||||
if (destroyed_) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "package already gc'd"));
|
||||
return;
|
||||
}
|
||||
CHECK(!key_blocks_only_);
|
||||
std::string value;
|
||||
auto R = kv_->get(get_db_key_block_info(block_id), value);
|
||||
R.ensure();
|
||||
if (R.move_as_ok() == td::KeyValue::GetStatus::NotFound) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "handle not in archive slice"));
|
||||
return;
|
||||
}
|
||||
auto E = create_block_handle(td::BufferSlice{value});
|
||||
E.ensure();
|
||||
auto handle = E.move_as_ok();
|
||||
if (!temp_) {
|
||||
handle->set_handle_moved_to_archive();
|
||||
}
|
||||
promise.set_value(std::move(handle));
|
||||
}
|
||||
|
||||
void ArchiveSlice::get_file(FileReference ref_id, td::Promise<td::BufferSlice> promise) {
|
||||
if (destroyed_) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "package already gc'd"));
|
||||
|
@ -231,7 +253,7 @@ void ArchiveSlice::get_file(FileReference ref_id, td::Promise<td::BufferSlice> p
|
|||
void ArchiveSlice::get_block_common(AccountIdPrefixFull account_id,
|
||||
std::function<td::int32(ton_api::db_lt_desc_value &)> compare_desc,
|
||||
std::function<td::int32(ton_api::db_lt_el_value &)> compare, bool exact,
|
||||
td::Promise<BlockHandle> promise) {
|
||||
td::Promise<ConstBlockHandle> promise) {
|
||||
if (destroyed_) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "package already gc'd"));
|
||||
return;
|
||||
|
@ -281,7 +303,7 @@ void ArchiveSlice::get_block_common(AccountIdPrefixFull account_id,
|
|||
lseq = create_block_id(e->id_);
|
||||
l = x;
|
||||
} else {
|
||||
get_handle(create_block_id(e->id_), std::move(promise));
|
||||
get_temp_handle(create_block_id(e->id_), std::move(promise));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +321,7 @@ void ArchiveSlice::get_block_common(AccountIdPrefixFull account_id,
|
|||
}
|
||||
if (block_id.is_valid() && ls + 1 == block_id.id.seqno) {
|
||||
if (!exact) {
|
||||
get_handle(block_id, std::move(promise));
|
||||
get_temp_handle(block_id, std::move(promise));
|
||||
} else {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "ltdb: block not found"));
|
||||
}
|
||||
|
@ -307,13 +329,14 @@ void ArchiveSlice::get_block_common(AccountIdPrefixFull account_id,
|
|||
}
|
||||
}
|
||||
if (!exact && block_id.is_valid()) {
|
||||
get_handle(block_id, std::move(promise));
|
||||
get_temp_handle(block_id, std::move(promise));
|
||||
} else {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "ltdb: block not found"));
|
||||
}
|
||||
}
|
||||
|
||||
void ArchiveSlice::get_block_by_lt(AccountIdPrefixFull account_id, LogicalTime lt, td::Promise<BlockHandle> promise) {
|
||||
void ArchiveSlice::get_block_by_lt(AccountIdPrefixFull account_id, LogicalTime lt,
|
||||
td::Promise<ConstBlockHandle> promise) {
|
||||
return get_block_common(
|
||||
account_id,
|
||||
[lt](ton_api::db_lt_desc_value &w) {
|
||||
|
@ -326,7 +349,7 @@ void ArchiveSlice::get_block_by_lt(AccountIdPrefixFull account_id, LogicalTime l
|
|||
}
|
||||
|
||||
void ArchiveSlice::get_block_by_seqno(AccountIdPrefixFull account_id, BlockSeqno seqno,
|
||||
td::Promise<BlockHandle> promise) {
|
||||
td::Promise<ConstBlockHandle> promise) {
|
||||
return get_block_common(
|
||||
account_id,
|
||||
[seqno](ton_api::db_lt_desc_value &w) {
|
||||
|
@ -343,7 +366,7 @@ void ArchiveSlice::get_block_by_seqno(AccountIdPrefixFull account_id, BlockSeqno
|
|||
}
|
||||
|
||||
void ArchiveSlice::get_block_by_unix_time(AccountIdPrefixFull account_id, UnixTime ts,
|
||||
td::Promise<BlockHandle> promise) {
|
||||
td::Promise<ConstBlockHandle> promise) {
|
||||
return get_block_common(
|
||||
account_id,
|
||||
[ts](ton_api::db_lt_desc_value &w) {
|
||||
|
|
|
@ -35,16 +35,17 @@ class ArchiveSlice : public td::actor::Actor {
|
|||
void update_handle(BlockHandle handle, td::Promise<td::Unit> promise);
|
||||
void add_file(FileReference ref_id, td::BufferSlice data, td::Promise<td::Unit> promise);
|
||||
void get_handle(BlockIdExt block_id, td::Promise<BlockHandle> promise);
|
||||
void get_temp_handle(BlockIdExt block_id, td::Promise<ConstBlockHandle> promise);
|
||||
void get_file(FileReference ref_id, td::Promise<td::BufferSlice> promise);
|
||||
|
||||
/* from LTDB */
|
||||
void get_block_by_unix_time(AccountIdPrefixFull account_id, UnixTime ts, td::Promise<BlockHandle> promise);
|
||||
void get_block_by_lt(AccountIdPrefixFull account_id, LogicalTime lt, td::Promise<BlockHandle> promise);
|
||||
void get_block_by_seqno(AccountIdPrefixFull account_id, BlockSeqno seqno, td::Promise<BlockHandle> promise);
|
||||
void get_block_by_unix_time(AccountIdPrefixFull account_id, UnixTime ts, td::Promise<ConstBlockHandle> promise);
|
||||
void get_block_by_lt(AccountIdPrefixFull account_id, LogicalTime lt, td::Promise<ConstBlockHandle> promise);
|
||||
void get_block_by_seqno(AccountIdPrefixFull account_id, BlockSeqno seqno, td::Promise<ConstBlockHandle> promise);
|
||||
void get_block_common(AccountIdPrefixFull account_id,
|
||||
std::function<td::int32(ton_api::db_lt_desc_value &)> compare_desc,
|
||||
std::function<td::int32(ton_api::db_lt_el_value &)> compare, bool exact,
|
||||
td::Promise<BlockHandle> promise);
|
||||
td::Promise<ConstBlockHandle> promise);
|
||||
|
||||
void get_slice(td::uint64 offset, td::uint32 limit, td::Promise<td::BufferSlice> promise);
|
||||
|
||||
|
|
|
@ -170,4 +170,8 @@ void Package::iterate(std::function<bool(std::string, td::BufferSlice, td::uint6
|
|||
}
|
||||
}
|
||||
|
||||
Package::~Package() {
|
||||
fd_.close();
|
||||
}
|
||||
|
||||
} // namespace ton
|
||||
|
|
|
@ -11,6 +11,8 @@ class Package {
|
|||
static td::Result<Package> open(std::string path, bool read_only = false, bool create = false);
|
||||
|
||||
Package(td::FileFd fd);
|
||||
Package(Package &&p) = default;
|
||||
~Package();
|
||||
|
||||
td::Status truncate(td::uint64 size);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ void RootDb::store_block_data(BlockHandle handle, td::Ref<BlockData> block, td::
|
|||
std::move(P));
|
||||
}
|
||||
|
||||
void RootDb::get_block_data(BlockHandle handle, td::Promise<td::Ref<BlockData>> promise) {
|
||||
void RootDb::get_block_data(ConstBlockHandle handle, td::Promise<td::Ref<BlockData>> promise) {
|
||||
if (!handle->received()) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "not in db"));
|
||||
} else {
|
||||
|
@ -88,7 +88,7 @@ void RootDb::store_block_signatures(BlockHandle handle, td::Ref<BlockSignatureSe
|
|||
data->serialize(), std::move(P));
|
||||
}
|
||||
|
||||
void RootDb::get_block_signatures(BlockHandle handle, td::Promise<td::Ref<BlockSignatureSet>> promise) {
|
||||
void RootDb::get_block_signatures(ConstBlockHandle handle, td::Promise<td::Ref<BlockSignatureSet>> promise) {
|
||||
if (!handle->inited_signatures() || handle->moved_to_archive()) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "not in db"));
|
||||
} else {
|
||||
|
@ -124,7 +124,7 @@ void RootDb::store_block_proof(BlockHandle handle, td::Ref<Proof> proof, td::Pro
|
|||
std::move(P));
|
||||
}
|
||||
|
||||
void RootDb::get_block_proof(BlockHandle handle, td::Promise<td::Ref<Proof>> promise) {
|
||||
void RootDb::get_block_proof(ConstBlockHandle handle, td::Promise<td::Ref<Proof>> promise) {
|
||||
if (!handle->inited_proof()) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "not in db"));
|
||||
} else {
|
||||
|
@ -159,7 +159,7 @@ void RootDb::store_block_proof_link(BlockHandle handle, td::Ref<ProofLink> proof
|
|||
proof->data(), std::move(P));
|
||||
}
|
||||
|
||||
void RootDb::get_block_proof_link(BlockHandle handle, td::Promise<td::Ref<ProofLink>> promise) {
|
||||
void RootDb::get_block_proof_link(ConstBlockHandle handle, td::Promise<td::Ref<ProofLink>> promise) {
|
||||
if (!handle->inited_proof_link()) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "not in db"));
|
||||
} else {
|
||||
|
@ -248,7 +248,7 @@ void RootDb::store_block_state(BlockHandle handle, td::Ref<ShardState> state,
|
|||
}
|
||||
}
|
||||
|
||||
void RootDb::get_block_state(BlockHandle handle, td::Promise<td::Ref<ShardState>> promise) {
|
||||
void RootDb::get_block_state(ConstBlockHandle handle, td::Promise<td::Ref<ShardState>> promise) {
|
||||
if (handle->inited_state_boc()) {
|
||||
if (handle->deleted_state_boc()) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::error, "state already gc'd"));
|
||||
|
@ -323,15 +323,15 @@ void RootDb::apply_block(BlockHandle handle, td::Promise<td::Unit> promise) {
|
|||
.release();
|
||||
}
|
||||
|
||||
void RootDb::get_block_by_lt(AccountIdPrefixFull account, LogicalTime lt, td::Promise<BlockHandle> promise) {
|
||||
void RootDb::get_block_by_lt(AccountIdPrefixFull account, LogicalTime lt, td::Promise<ConstBlockHandle> promise) {
|
||||
td::actor::send_closure(archive_db_, &ArchiveManager::get_block_by_lt, account, lt, std::move(promise));
|
||||
}
|
||||
|
||||
void RootDb::get_block_by_unix_time(AccountIdPrefixFull account, UnixTime ts, td::Promise<BlockHandle> promise) {
|
||||
void RootDb::get_block_by_unix_time(AccountIdPrefixFull account, UnixTime ts, td::Promise<ConstBlockHandle> promise) {
|
||||
td::actor::send_closure(archive_db_, &ArchiveManager::get_block_by_unix_time, account, ts, std::move(promise));
|
||||
}
|
||||
|
||||
void RootDb::get_block_by_seqno(AccountIdPrefixFull account, BlockSeqno seqno, td::Promise<BlockHandle> promise) {
|
||||
void RootDb::get_block_by_seqno(AccountIdPrefixFull account, BlockSeqno seqno, td::Promise<ConstBlockHandle> promise) {
|
||||
td::actor::send_closure(archive_db_, &ArchiveManager::get_block_by_seqno, account, seqno, std::move(promise));
|
||||
}
|
||||
|
||||
|
|
|
@ -41,17 +41,17 @@ class RootDb : public Db {
|
|||
void start_up() override;
|
||||
|
||||
void store_block_data(BlockHandle handle, td::Ref<BlockData> block, td::Promise<td::Unit> promise) override;
|
||||
void get_block_data(BlockHandle handle, td::Promise<td::Ref<BlockData>> promise) override;
|
||||
void get_block_data(ConstBlockHandle handle, td::Promise<td::Ref<BlockData>> promise) override;
|
||||
|
||||
void store_block_signatures(BlockHandle handle, td::Ref<BlockSignatureSet> data,
|
||||
td::Promise<td::Unit> promise) override;
|
||||
void get_block_signatures(BlockHandle handle, td::Promise<td::Ref<BlockSignatureSet>> promise) override;
|
||||
void get_block_signatures(ConstBlockHandle handle, td::Promise<td::Ref<BlockSignatureSet>> promise) override;
|
||||
|
||||
void store_block_proof(BlockHandle handle, td::Ref<Proof> proof, td::Promise<td::Unit> promise) override;
|
||||
void get_block_proof(BlockHandle handle, td::Promise<td::Ref<Proof>> promise) override;
|
||||
void get_block_proof(ConstBlockHandle handle, td::Promise<td::Ref<Proof>> promise) override;
|
||||
|
||||
void store_block_proof_link(BlockHandle handle, td::Ref<ProofLink> proof, td::Promise<td::Unit> promise) override;
|
||||
void get_block_proof_link(BlockHandle handle, td::Promise<td::Ref<ProofLink>> promise) override;
|
||||
void get_block_proof_link(ConstBlockHandle handle, td::Promise<td::Ref<ProofLink>> promise) override;
|
||||
|
||||
void store_block_candidate(BlockCandidate candidate, td::Promise<td::Unit> promise) override;
|
||||
void get_block_candidate(PublicKey source, BlockIdExt id, FileHash collated_data_file_hash,
|
||||
|
@ -59,7 +59,7 @@ class RootDb : public Db {
|
|||
|
||||
void store_block_state(BlockHandle handle, td::Ref<ShardState> state,
|
||||
td::Promise<td::Ref<ShardState>> promise) override;
|
||||
void get_block_state(BlockHandle handle, td::Promise<td::Ref<ShardState>> promise) override;
|
||||
void get_block_state(ConstBlockHandle handle, td::Promise<td::Ref<ShardState>> promise) override;
|
||||
|
||||
void store_block_handle(BlockHandle handle, td::Promise<td::Unit> promise) override;
|
||||
void get_block_handle(BlockIdExt id, td::Promise<BlockHandle> promise) override;
|
||||
|
@ -82,9 +82,9 @@ class RootDb : public Db {
|
|||
void try_get_static_file(FileHash file_hash, td::Promise<td::BufferSlice> promise) override;
|
||||
|
||||
void apply_block(BlockHandle handle, td::Promise<td::Unit> promise) override;
|
||||
void get_block_by_lt(AccountIdPrefixFull account, LogicalTime lt, td::Promise<BlockHandle> promise) override;
|
||||
void get_block_by_unix_time(AccountIdPrefixFull account, UnixTime ts, td::Promise<BlockHandle> promise) override;
|
||||
void get_block_by_seqno(AccountIdPrefixFull account, BlockSeqno seqno, td::Promise<BlockHandle> promise) override;
|
||||
void get_block_by_lt(AccountIdPrefixFull account, LogicalTime lt, td::Promise<ConstBlockHandle> promise) override;
|
||||
void get_block_by_unix_time(AccountIdPrefixFull account, UnixTime ts, td::Promise<ConstBlockHandle> promise) override;
|
||||
void get_block_by_seqno(AccountIdPrefixFull account, BlockSeqno seqno, td::Promise<ConstBlockHandle> promise) override;
|
||||
|
||||
void update_init_masterchain_block(BlockIdExt block, td::Promise<td::Unit> promise) override;
|
||||
void get_init_masterchain_block(td::Promise<BlockIdExt> promise) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue