mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
initial commit
This commit is contained in:
commit
c2da007f40
1610 changed files with 398047 additions and 0 deletions
94
validator/impl/proof.hpp
Normal file
94
validator/impl/proof.hpp
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
TON Blockchain Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2019 Telegram Systems LLP
|
||||
*/
|
||||
#pragma once
|
||||
#include "interfaces/proof.h"
|
||||
#include "interfaces/config.h"
|
||||
#include "block/block-db.h"
|
||||
#include "block/mc-config.h"
|
||||
#include "vm/db/StaticBagOfCellsDb.h"
|
||||
|
||||
namespace ton {
|
||||
namespace validator {
|
||||
using td::Ref;
|
||||
|
||||
class ConfigHolderQ : public ConfigHolder {
|
||||
std::shared_ptr<block::Config> config_;
|
||||
std::shared_ptr<vm::StaticBagOfCellsDb> boc_;
|
||||
|
||||
public:
|
||||
ConfigHolderQ() = default;
|
||||
ConfigHolderQ(std::shared_ptr<block::Config> config, std::shared_ptr<vm::StaticBagOfCellsDb> boc)
|
||||
: config_(std::move(config)), boc_(std::move(boc)) {
|
||||
}
|
||||
ConfigHolderQ(std::shared_ptr<block::Config> config) : config_(std::move(config)) {
|
||||
}
|
||||
const block::Config *get_config() const {
|
||||
return config_.get();
|
||||
}
|
||||
ConfigHolderQ *make_copy() const override {
|
||||
return new ConfigHolderQ(*this);
|
||||
}
|
||||
// if necessary, add more public methods providing interface to config_->...()
|
||||
td::Ref<ValidatorSet> get_total_validator_set(int next) const override; // next = -1 -> prev, next = 0 -> cur
|
||||
};
|
||||
|
||||
class ProofLinkQ : virtual public ProofLink {
|
||||
protected:
|
||||
BlockIdExt id_;
|
||||
td::BufferSlice data_;
|
||||
|
||||
public:
|
||||
ProofLinkQ(const BlockIdExt &id, td::BufferSlice data) : id_(id), data_(std::move(data)) {
|
||||
}
|
||||
ProofLinkQ *make_copy() const override {
|
||||
return new ProofLinkQ(id_, data_.clone());
|
||||
}
|
||||
BlockIdExt block_id() const override {
|
||||
return id_;
|
||||
}
|
||||
td::BufferSlice data() const override {
|
||||
return data_.clone();
|
||||
}
|
||||
td::Result<BlockSeqno> prev_key_mc_seqno() const override;
|
||||
td::Result<td::Ref<ConfigHolder>> get_key_block_config() const override;
|
||||
|
||||
protected:
|
||||
td::Result<std::pair<Ref<vm::Cell>, std::shared_ptr<vm::StaticBagOfCellsDb>>> get_virtual_root(
|
||||
bool lazy = false) const;
|
||||
};
|
||||
|
||||
#if TD_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4250) // Proof is an interface, so there is no problem here
|
||||
#endif
|
||||
class ProofQ : public Proof, public ProofLinkQ {
|
||||
public:
|
||||
ProofQ(BlockIdExt masterchain_block_id, td::BufferSlice data) : ProofLinkQ(masterchain_block_id, std::move(data)) {
|
||||
}
|
||||
ProofQ *make_copy() const override {
|
||||
return new ProofQ(id_, data_.clone());
|
||||
}
|
||||
td::Result<Ref<ProofLink>> export_as_proof_link() const override;
|
||||
};
|
||||
#if TD_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} // namespace validator
|
||||
} // namespace ton
|
Loading…
Add table
Add a link
Reference in a new issue