TARAXA
block.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 
6 #include "BlockObject.h"
9 
10 namespace graphql::taraxa {
11 class Block {
12  public:
13  explicit Block(std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain,
14  std::shared_ptr<::taraxa::TransactionManager> trx_manager,
15  std::function<std::shared_ptr<object::Block>(::taraxa::EthBlockNumber)> get_block_by_num,
16  const ::taraxa::blk_hash_t& pbft_block_hash,
17  std::shared_ptr<const ::taraxa::final_chain::BlockHeader> block_header) noexcept;
18 
19  response::Value getNumber() const noexcept;
20  response::Value getHash() const noexcept;
21  response::Value getPbftHash() const noexcept;
22  std::shared_ptr<object::Block> getParent() const noexcept;
23  response::Value getNonce() const noexcept;
24  response::Value getTransactionsRoot() const noexcept;
25  std::optional<int> getTransactionCount() const noexcept;
26  response::Value getStateRoot() const noexcept;
27  response::Value getReceiptsRoot() const noexcept;
28  std::shared_ptr<object::Account> getMiner(std::optional<response::Value>&& blockArg) const;
29  response::Value getExtraData() const noexcept;
30  response::Value getGasLimit() const noexcept;
31  response::Value getGasUsed() const noexcept;
32  response::Value getTimestamp() const noexcept;
33  response::Value getLogsBloom() const noexcept;
34  response::Value getMixHash() const noexcept;
35  response::Value getDifficulty() const noexcept;
36  response::Value getTotalDifficulty() const noexcept;
37  std::optional<int> getOmmerCount() const noexcept;
38  std::optional<std::vector<std::shared_ptr<object::Block>>> getOmmers() const noexcept;
39  std::shared_ptr<object::Block> getOmmerAt(int&& indexArg) const noexcept;
40  response::Value getOmmerHash() const noexcept;
41  std::optional<std::vector<std::shared_ptr<object::Transaction>>> getTransactions() const noexcept;
42  std::shared_ptr<object::Transaction> getTransactionAt(response::IntType&& indexArg) const noexcept;
43  std::vector<std::shared_ptr<object::Log>> getLogs(BlockFilterCriteria&& filterArg) const noexcept;
44  std::shared_ptr<object::Account> getAccount(response::Value&& addressArg) const;
45  std::shared_ptr<object::CallResult> getCall(CallData&& dataArg) const noexcept;
46  response::Value getEstimateGas(CallData&& dataArg) const noexcept;
47 
48  private:
49  std::shared_ptr<::taraxa::final_chain::FinalChain> final_chain_;
50  std::shared_ptr<::taraxa::TransactionManager> trx_manager_;
51  std::function<std::shared_ptr<object::Block>(::taraxa::EthBlockNumber)> get_block_by_num_;
53  std::shared_ptr<const ::taraxa::final_chain::BlockHeader> block_header_;
54  mutable std::vector<std::shared_ptr<::taraxa::Transaction>> transactions_;
55 };
56 
57 } // namespace graphql::taraxa
Definition: block.hpp:11
response::Value getGasUsed() const noexcept
Definition: block.cpp:70
response::Value getDifficulty() const noexcept
Definition: block.cpp:82
std::optional< int > getTransactionCount() const noexcept
Definition: block.cpp:41
response::Value getPbftHash() const noexcept
Definition: block.cpp:29
std::shared_ptr< object::Transaction > getTransactionAt(response::IntType &&indexArg) const noexcept
Definition: block.cpp:110
response::Value getNonce() const noexcept
Definition: block.cpp:35
std::optional< int > getOmmerCount() const noexcept
Definition: block.cpp:88
std::vector< std::shared_ptr< object::Log > > getLogs(BlockFilterCriteria &&filterArg) const noexcept
Definition: block.cpp:122
const ::taraxa::blk_hash_t kPBftBlockHash
Definition: block.hpp:52
response::Value getMixHash() const noexcept
Definition: block.cpp:80
std::vector< std::shared_ptr<::taraxa::Transaction > > transactions_
Definition: block.hpp:54
std::shared_ptr<::taraxa::final_chain::FinalChain > final_chain_
Definition: block.hpp:49
response::Value getHash() const noexcept
Definition: block.cpp:27
response::Value getReceiptsRoot() const noexcept
Definition: block.cpp:51
response::Value getNumber() const noexcept
Definition: block.cpp:25
response::Value getTransactionsRoot() const noexcept
Definition: block.cpp:37
std::shared_ptr< object::Block > getParent() const noexcept
Definition: block.cpp:31
response::Value getEstimateGas(CallData &&dataArg) const noexcept
Definition: block.cpp:134
std::shared_ptr< const ::taraxa::final_chain::BlockHeader > block_header_
Definition: block.hpp:53
std::optional< std::vector< std::shared_ptr< object::Transaction > > > getTransactions() const noexcept
Definition: block.cpp:96
std::shared_ptr< object::CallResult > getCall(CallData &&dataArg) const noexcept
Definition: block.cpp:132
response::Value getGasLimit() const noexcept
Definition: block.cpp:66
response::Value getOmmerHash() const noexcept
Definition: block.cpp:94
response::Value getTimestamp() const noexcept
Definition: block.cpp:74
response::Value getStateRoot() const noexcept
Definition: block.cpp:49
Block(std::shared_ptr<::taraxa::final_chain::FinalChain > final_chain, std::shared_ptr<::taraxa::TransactionManager > trx_manager, std::function< std::shared_ptr< object::Block >(::taraxa::EthBlockNumber)> get_block_by_num, const ::taraxa::blk_hash_t &pbft_block_hash, std::shared_ptr< const ::taraxa::final_chain::BlockHeader > block_header) noexcept
Definition: block.cpp:14
std::function< std::shared_ptr< object::Block >::taraxa::EthBlockNumber)> get_block_by_num_
Definition: block.hpp:51
std::shared_ptr< object::Account > getAccount(response::Value &&addressArg) const
Definition: block.cpp:127
std::optional< std::vector< std::shared_ptr< object::Block > > > getOmmers() const noexcept
Definition: block.cpp:90
response::Value getExtraData() const noexcept
Definition: block.cpp:64
std::shared_ptr< object::Account > getMiner(std::optional< response::Value > &&blockArg) const
Definition: block.cpp:55
response::Value getLogsBloom() const noexcept
Definition: block.cpp:78
std::shared_ptr< object::Block > getOmmerAt(int &&indexArg) const noexcept
Definition: block.cpp:92
std::shared_ptr<::taraxa::TransactionManager > trx_manager_
Definition: block.hpp:50
response::Value getTotalDifficulty() const noexcept
Definition: block.cpp:84
Definition: account.hpp:10
uint64_t EthBlockNumber
Definition: types.hpp:23
uint256_hash_t blk_hash_t
Definition: types.hpp:42