Kagome
Polkadot Runtime Engine in C++17
block_builder.cpp
Go to the documentation of this file.
1 
7 
9 
10 namespace kagome::runtime {
11 
12  BlockBuilderImpl::BlockBuilderImpl(std::shared_ptr<Executor> executor)
13  : executor_{std::move(executor)} {
14  BOOST_ASSERT(executor_);
15  }
16 
17  outcome::result<PersistentResult<primitives::ApplyExtrinsicResult>>
19  storage::trie::RootHash const &storage_hash,
20  const primitives::Extrinsic &extrinsic) {
21  return executor_->persistentCallAt<primitives::ApplyExtrinsicResult>(
22  block, storage_hash, "BlockBuilder_apply_extrinsic", extrinsic);
23  }
24 
25  outcome::result<primitives::BlockHeader> BlockBuilderImpl::finalize_block(
26  const primitives::BlockInfo &block,
27  storage::trie::RootHash const &storage_hash) {
28  const auto res = executor_->persistentCallAt<primitives::BlockHeader>(
29  block, storage_hash, "BlockBuilder_finalize_block");
30  if (res) return res.value().result;
31  return res.error();
32  }
33 
34  outcome::result<std::vector<primitives::Extrinsic>>
36  const primitives::BlockInfo &block,
37  storage::trie::RootHash const &storage_hash,
38  const primitives::InherentData &data) {
39  return executor_->callAt<std::vector<primitives::Extrinsic>>(
40  block, storage_hash, "BlockBuilder_inherent_extrinsics", data);
41  }
42 
43  outcome::result<primitives::CheckInherentsResult>
45  const primitives::InherentData &data) {
47  block.header.parent_hash, "BlockBuilder_check_inherents", block, data);
48  }
49 
50  outcome::result<common::Hash256> BlockBuilderImpl::random_seed(
51  const primitives::BlockHash &block) {
52  return executor_->callAt<common::Hash256>(block,
53  "BlockBuilder_random_seed");
54  }
55 
56 } // namespace kagome::runtime
outcome::result< std::vector< primitives::Extrinsic > > inherent_extrinsics(const primitives::BlockInfo &block, storage::trie::RootHash const &storage_hash, const primitives::InherentData &data) override
outcome::result< primitives::CheckInherentsResult > check_inherents(const primitives::Block &block, const primitives::InherentData &data) override
BlockBuilderImpl(std::shared_ptr< Executor > executor)
Block class represents polkadot block primitive.
Definition: block.hpp:19
std::shared_ptr< Executor > executor_
boost::variant< DispatchOutcome, TransactionValidityError > ApplyExtrinsicResult
outcome::result< common::Hash256 > random_seed(const primitives::BlockHash &block) override
outcome::result< PersistentResult< primitives::ApplyExtrinsicResult > > apply_extrinsic(const primitives::BlockInfo &block, storage::trie::RootHash const &storage_hash, const primitives::Extrinsic &extrinsic) override
BlockHeader header
block header
Definition: block.hpp:22
Extrinsic class represents extrinsic.
Definition: extrinsic.hpp:24
BlockHash parent_hash
32-byte Blake2s hash of parent header
result of check_inherents method of BlockBuilder runtime api
outcome::result< primitives::BlockHeader > finalize_block(const primitives::BlockInfo &block, storage::trie::RootHash const &storage_hash) override