Kagome
Polkadot Runtime Engine in C++17
grandpa_api.cpp
Go to the documentation of this file.
1 
7 
9 
10 namespace kagome::runtime {
11 
13  std::shared_ptr<blockchain::BlockHeaderRepository> block_header_repo,
14  std::shared_ptr<Executor> executor)
15  : block_header_repo_{std::move(block_header_repo)},
16  executor_{std::move(executor)} {
17  BOOST_ASSERT(block_header_repo_);
18  BOOST_ASSERT(executor_);
19  }
20 
21  outcome::result<std::optional<GrandpaApi::ScheduledChange>>
23  const Digest &digest) {
24  return executor_->callAt<std::optional<ScheduledChange>>(
25  block, "GrandpaApi_pending_change", digest);
26  }
27 
28  outcome::result<std::optional<GrandpaApi::ForcedChange>>
30  const Digest &digest) {
31  return executor_->callAt<std::optional<ForcedChange>>(
32  block, "GrandpaApi_forced_change", digest);
33  }
34 
35  outcome::result<GrandpaApi::AuthorityList> GrandpaApiImpl::authorities(
36  const primitives::BlockId &block_id) {
37  OUTCOME_TRY(block_hash, block_header_repo_->getHashById(block_id));
38  return executor_->callAt<AuthorityList>(block_hash,
39  "GrandpaApi_grandpa_authorities");
40  }
41 
42  outcome::result<primitives::AuthoritySetId> GrandpaApiImpl::current_set_id(
43  const primitives::BlockHash &block_hash) {
44  return executor_->callAt<primitives::AuthoritySetId>(
45  block_hash, "GrandpaApi_current_set_id");
46  }
47 
48 } // namespace kagome::runtime
GrandpaApiImpl(std::shared_ptr< blockchain::BlockHeaderRepository > block_header_repo, std::shared_ptr< Executor > executor)
Definition: grandpa_api.cpp:12
std::shared_ptr< Executor > executor_
Definition: grandpa_api.hpp:37
outcome::result< AuthorityList > authorities(const primitives::BlockId &block_id) override
calls Grandpa_authorities runtime api function
Definition: grandpa_api.cpp:35
outcome::result< primitives::AuthoritySetId > current_set_id(const primitives::BlockHash &block) override
Definition: grandpa_api.cpp:42
outcome::result< std::optional< ScheduledChange > > pending_change(primitives::BlockHash const &block, const Digest &digest) override
calls Grandpa_pending_change runtime api function, which checks a digest for pending changes...
Definition: grandpa_api.cpp:22
outcome::result< std::optional< ForcedChange > > forced_change(primitives::BlockHash const &block, const Digest &digest) override
calls Grandpa_forced_change runtime api function which checks a digest for forced changes ...
Definition: grandpa_api.cpp:29
uint64_t AuthoritySetId
Definition: authority.hpp:20
std::shared_ptr< blockchain::BlockHeaderRepository > block_header_repo_
Definition: grandpa_api.hpp:36
boost::variant< BlockHash, BlockNumber > BlockId
Block id is the variant over BlockHash and BlockNumber.
Definition: block_id.hpp:18