1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Changes in CollatorNode

This commit is contained in:
SpyCheese 2023-07-12 09:01:15 +03:00
parent f10c7f54a8
commit d5a56b7c2b
2 changed files with 194 additions and 78 deletions

View file

@ -18,6 +18,7 @@
#include "interfaces/validator-manager.h"
#include "rldp/rldp.h"
#include <map>
namespace ton {
@ -38,11 +39,11 @@ class CollatorNode : public td::actor::Actor {
private:
void receive_query(adnl::AdnlNodeIdShort src, td::BufferSlice data, td::Promise<td::BufferSlice> promise);
void receive_query_cont(adnl::AdnlNodeIdShort src, ShardIdFull shard, td::Ref<MasterchainState> min_mc_state,
void receive_query_cont(ShardIdFull shard, td::Ref<MasterchainState> min_mc_state,
std::vector<BlockIdExt> prev_blocks, Ed25519_PublicKey creator,
td::Promise<td::BufferSlice> promise);
td::Promise<BlockCandidate> promise);
bool collate_shard(ShardIdFull shard) const;
bool can_collate_shard(ShardIdFull shard) const;
adnl::AdnlNodeIdShort local_id_;
td::actor::ActorId<ValidatorManager> manager_;
@ -50,6 +51,32 @@ class CollatorNode : public td::actor::Actor {
td::actor::ActorId<rldp::Rldp> rldp_;
std::vector<ShardIdFull> shards_;
std::set<adnl::AdnlNodeIdShort> validators_;
BlockIdExt last_masterchain_block_{};
std::map<ShardIdFull, BlockIdExt> last_top_blocks_;
struct CacheEntry {
bool started = false;
td::optional<BlockCandidate> result;
std::vector<td::Promise<BlockCandidate>> promises;
};
std::map<std::tuple<BlockSeqno, ShardIdFull, std::vector<BlockIdExt>>, std::shared_ptr<CacheEntry>> cache_;
td::optional<BlockIdExt> get_shard_top_block(ShardIdFull shard) const {
auto it = last_top_blocks_.lower_bound(shard);
if (it != last_top_blocks_.end() && shard_intersects(it->first, shard)) {
return it->second;
}
if (it != last_top_blocks_.begin()) {
--it;
if (shard_intersects(it->first, shard)) {
return it->second;
}
}
return {};
}
void process_result(std::shared_ptr<CacheEntry> cache_entry, td::Result<BlockCandidate> R);
};
} // namespace validator