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
114
catchain/catchain-received-block.h
Normal file
114
catchain/catchain-received-block.h
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
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 "td/utils/buffer.h"
|
||||
#include "td/utils/SharedSlice.h"
|
||||
#include "auto/tl/ton_api.h"
|
||||
|
||||
#include "catchain/catchain-receiver.h"
|
||||
|
||||
namespace ton {
|
||||
|
||||
namespace catchain {
|
||||
|
||||
class CatChainReceiver;
|
||||
class CatChainReceiverSource;
|
||||
class CatChainReceiverFork;
|
||||
|
||||
class CatChainReceivedBlock {
|
||||
public:
|
||||
// getters
|
||||
virtual const td::SharedSlice &get_payload() const = 0;
|
||||
virtual CatChainBlockHash get_hash() const = 0;
|
||||
virtual const td::SharedSlice &get_signature() const = 0;
|
||||
|
||||
virtual CatChainBlockHeight get_height() const = 0;
|
||||
virtual CatChainReceivedBlock *get_prev() const = 0;
|
||||
virtual CatChainBlockHash get_prev_hash() const = 0;
|
||||
|
||||
virtual const std::vector<CatChainBlockHeight> &get_deps() const = 0;
|
||||
virtual std::vector<CatChainBlockHash> get_dep_hashes() const = 0;
|
||||
|
||||
virtual CatChainReceiver *get_chain() const = 0;
|
||||
|
||||
virtual td::uint32 get_fork_id() const = 0;
|
||||
virtual td::uint32 get_source_id() const = 0;
|
||||
|
||||
virtual tl_object_ptr<ton_api::catchain_block> export_tl() const = 0;
|
||||
virtual tl_object_ptr<ton_api::catchain_block_dep> export_tl_dep() const = 0;
|
||||
|
||||
virtual void find_pending_deps(std::vector<CatChainBlockHash> &vec, td::uint32 max_size) const = 0;
|
||||
|
||||
public:
|
||||
// state
|
||||
virtual bool initialized() const = 0;
|
||||
virtual bool delivered() const = 0;
|
||||
virtual bool is_ill() const = 0;
|
||||
virtual bool is_custom() const = 0;
|
||||
virtual bool in_db() const = 0;
|
||||
|
||||
public:
|
||||
//change state
|
||||
virtual void initialize(tl_object_ptr<ton_api::catchain_block> block, td::SharedSlice payload) = 0;
|
||||
virtual void set_ill() = 0;
|
||||
virtual void written() = 0;
|
||||
virtual void run() = 0;
|
||||
|
||||
public:
|
||||
static std::unique_ptr<CatChainReceivedBlock> create(tl_object_ptr<ton_api::catchain_block> block,
|
||||
td::SharedSlice payload, CatChainReceiver *chain);
|
||||
static std::unique_ptr<CatChainReceivedBlock> create(tl_object_ptr<ton_api::catchain_block_dep> block,
|
||||
CatChainReceiver *chain);
|
||||
static std::unique_ptr<CatChainReceivedBlock> create_root(td::uint32 source_id, CatChainBlockPayloadHash data_hash,
|
||||
CatChainReceiver *chain);
|
||||
|
||||
static tl_object_ptr<ton_api::catchain_block_id> block_id(CatChainReceiver *chain,
|
||||
tl_object_ptr<ton_api::catchain_block> &block,
|
||||
td::Slice payload);
|
||||
static tl_object_ptr<ton_api::catchain_block_id> block_id(CatChainReceiver *chain,
|
||||
tl_object_ptr<ton_api::catchain_block_dep> &block);
|
||||
static CatChainBlockHash block_hash(CatChainReceiver *chain, tl_object_ptr<ton_api::catchain_block> &block,
|
||||
td::Slice payload);
|
||||
static CatChainBlockHash block_hash(CatChainReceiver *chain, tl_object_ptr<ton_api::catchain_block_dep> &block);
|
||||
static td::Status pre_validate_block(CatChainReceiver *chain, tl_object_ptr<ton_api::catchain_block> &block,
|
||||
td::Slice payload);
|
||||
static td::Status pre_validate_block(CatChainReceiver *chain, tl_object_ptr<ton_api::catchain_block_dep> &block);
|
||||
|
||||
virtual ~CatChainReceivedBlock() = default;
|
||||
};
|
||||
|
||||
} // namespace catchain
|
||||
|
||||
} // namespace ton
|
||||
|
||||
namespace td {
|
||||
|
||||
inline td::StringBuilder &operator<<(td::StringBuilder &sb, const ton::catchain::CatChainReceivedBlock &block) {
|
||||
sb << "[block " << block.get_chain()->get_incarnation() << " " << block.get_source_id() << " " << block.get_fork_id()
|
||||
<< " " << block.get_hash() << "]";
|
||||
return sb;
|
||||
}
|
||||
inline td::StringBuilder &operator<<(td::StringBuilder &sb, const ton::catchain::CatChainReceivedBlock *block) {
|
||||
sb << *block;
|
||||
return sb;
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue