mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Add more recent blocks to "previous blocks info"
This commit is contained in:
parent
f03f6ce7ca
commit
a01c7e2e75
3 changed files with 34 additions and 8 deletions
|
@ -2292,7 +2292,8 @@ Ref<vm::Cell> ConfigInfo::lookup_library(td::ConstBitPtr root_hash) const {
|
|||
td::Result<Ref<vm::Tuple>> ConfigInfo::get_prev_blocks_info() const {
|
||||
// [ wc:Integer shard:Integer seqno:Integer root_hash:Integer file_hash:Integer] = BlockId;
|
||||
// [ last_mc_blocks:[BlockId...]
|
||||
// prev_key_block:BlockId ] : PrevBlocksInfo
|
||||
// prev_key_block:BlockId
|
||||
// last_mc_blocks_100[BlockId...] ] : PrevBlocksInfo
|
||||
auto block_id_to_tuple = [](const ton::BlockIdExt& block_id) -> vm::Ref<vm::Tuple> {
|
||||
td::RefInt256 shard = td::make_refint(block_id.id.shard);
|
||||
if (shard->sgn() < 0) {
|
||||
|
@ -2302,25 +2303,44 @@ td::Result<Ref<vm::Tuple>> ConfigInfo::get_prev_blocks_info() const {
|
|||
td::make_refint(block_id.id.seqno), td::bits_to_refint(block_id.root_hash.bits(), 256),
|
||||
td::bits_to_refint(block_id.file_hash.bits(), 256));
|
||||
};
|
||||
std::vector<vm::StackEntry> last_mc_blocks;
|
||||
std::vector<vm::StackEntry> tuple;
|
||||
|
||||
std::vector<vm::StackEntry> last_mc_blocks;
|
||||
last_mc_blocks.push_back(block_id_to_tuple(block_id));
|
||||
for (ton::BlockSeqno seqno = block_id.id.seqno; seqno > 0 && last_mc_blocks.size() < 16;) {
|
||||
--seqno;
|
||||
ton::BlockIdExt block_id;
|
||||
if (!get_old_mc_block_id(seqno, block_id)) {
|
||||
ton::BlockIdExt id;
|
||||
if (!get_old_mc_block_id(seqno, id)) {
|
||||
return td::Status::Error("cannot fetch old mc block");
|
||||
}
|
||||
last_mc_blocks.push_back(block_id_to_tuple(block_id));
|
||||
last_mc_blocks.push_back(block_id_to_tuple(id));
|
||||
}
|
||||
tuple.push_back(td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks)));
|
||||
|
||||
ton::BlockIdExt last_key_block;
|
||||
ton::LogicalTime last_key_block_lt;
|
||||
if (!get_last_key_block(last_key_block, last_key_block_lt)) {
|
||||
return td::Status::Error("cannot fetch last key block");
|
||||
}
|
||||
return vm::make_tuple_ref(td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks)),
|
||||
block_id_to_tuple(last_key_block));
|
||||
tuple.push_back(block_id_to_tuple(last_key_block));
|
||||
|
||||
if (get_global_version() >= 9) {
|
||||
std::vector<vm::StackEntry> last_mc_blocks_100;
|
||||
for (ton::BlockSeqno seqno = block_id.id.seqno / 100 * 100; last_mc_blocks_100.size() < 16;) {
|
||||
ton::BlockIdExt id;
|
||||
if (!get_old_mc_block_id(seqno, id)) {
|
||||
return td::Status::Error("cannot fetch old mc block");
|
||||
}
|
||||
last_mc_blocks_100.push_back(block_id_to_tuple(id));
|
||||
if (seqno < 100) {
|
||||
break;
|
||||
}
|
||||
seqno -= 100;
|
||||
}
|
||||
tuple.push_back(td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks_100)));
|
||||
}
|
||||
|
||||
return td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(tuple));
|
||||
}
|
||||
|
||||
td::optional<PrecompiledContractsConfig::Contract> PrecompiledContractsConfig::get_contract(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue