10 #include <jsonrpc-lean/request.h> 14 #include "scale/scale.hpp" 20 std::shared_ptr<application::ChainSpec> config,
21 std::shared_ptr<consensus::babe::Babe> babe,
22 std::shared_ptr<network::PeerManager> peer_manager,
23 std::shared_ptr<runtime::AccountNonceApi> account_nonce_api,
24 std::shared_ptr<transaction_pool::TransactionPool> transaction_pool,
25 std::shared_ptr<const blockchain::BlockTree> block_tree,
26 std::shared_ptr<crypto::Hasher> hasher)
27 : config_(
std::move(config)),
28 babe_(
std::move(babe)),
29 peer_manager_(
std::move(peer_manager)),
30 account_nonce_api_(
std::move(account_nonce_api)),
31 transaction_pool_(
std::move(transaction_pool)),
32 block_tree_(
std::move(block_tree)),
33 hasher_{std::move(hasher)} {
34 BOOST_ASSERT(
config_ !=
nullptr);
35 BOOST_ASSERT(
babe_ !=
nullptr);
39 BOOST_ASSERT(
hasher_ !=
nullptr);
56 std::string_view account_address)
const {
72 std::reference_wrapper<const primitives::Transaction>>
75 for (
auto &[tx_hash, tx_ptr] : txs) {
76 if (tx_ptr->provides.empty())
continue;
80 auto tag_decode_res = scale::decode<
81 std::tuple<primitives::AccountId, primitives::AccountNonce>>(
82 tx_ptr->provides.at(0));
85 if (tag_decode_res.has_value()) {
86 auto &&[id, nonce] = std::move(tag_decode_res.value());
87 if (
id == account_id) {
88 sorted_txs.emplace(nonce, std::ref(*tx_ptr));
93 for (
auto &&[tx_nonce, tx] : sorted_txs) {
94 if (tx_nonce == current_nonce) {
101 return current_nonce;
std::shared_ptr< runtime::AccountNonceApi > account_nonce_api_
std::shared_ptr< transaction_pool::TransactionPool > transaction_pool_
outcome::result< primitives::AccountNonce > getNonceFor(std::string_view account_address) const override
std::shared_ptr< crypto::Hasher > hasher_
std::shared_ptr< network::PeerManager > getPeerManager() const override
std::shared_ptr< consensus::babe::Babe > babe_
primitives::AccountNonce adjustNonce(const primitives::AccountId &account_id, primitives::AccountNonce current_nonce) const
std::shared_ptr< const blockchain::BlockTree > block_tree_
outcome::result< AccountId > decodeSs58(std::string_view account_address, const crypto::Hasher &hasher) noexcept
std::shared_ptr< application::ChainSpec > getConfig() const override
crypto::Sr25519PublicKey AccountId
std::shared_ptr< network::PeerManager > peer_manager_
std::shared_ptr< application::ChainSpec > config_
std::shared_ptr< consensus::babe::Babe > getBabe() const override
SystemApiImpl(std::shared_ptr< application::ChainSpec > config, std::shared_ptr< consensus::babe::Babe > babe, std::shared_ptr< network::PeerManager > peer_manager, std::shared_ptr< runtime::AccountNonceApi > account_nonce_api, std::shared_ptr< transaction_pool::TransactionPool > transaction_pool, std::shared_ptr< const blockchain::BlockTree > block_tree, std::shared_ptr< crypto::Hasher > hasher)