TARAXA
period_data.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <libdevcore/Common.h>
4 #include <libdevcore/RLP.h>
5 
6 #include <vector>
7 
8 #include "common/types.hpp"
9 #include "dag/dag_block.hpp"
11 
12 namespace taraxa {
13 
18 class PbftVote;
19 class PbftBlock;
20 class PillarVote;
21 
25 class PeriodData {
26  public:
27  PeriodData() = default;
28  PeriodData(std::shared_ptr<PbftBlock> pbft_blk,
29  const std::vector<std::shared_ptr<PbftVote>>& previous_block_cert_votes,
30  std::optional<std::vector<std::shared_ptr<PillarVote>>>&& pillar_votes = {});
31  explicit PeriodData(const dev::RLP& all_rlp);
32  explicit PeriodData(const bytes& all_rlp);
33 
35  static bytes ToOldPeriodData(const bytes& rlp);
36 
37  std::shared_ptr<PbftBlock> pbft_blk;
38  std::vector<std::shared_ptr<PbftVote>> previous_block_cert_votes; // These votes are the cert votes of previous block
39  // which match reward votes in current pbft block
40  std::vector<DagBlock> dag_blocks;
42 
43  // Pillar votes should be present only if pbft block contains also pillar block hash
44  std::optional<std::vector<std::shared_ptr<PillarVote>>> pillar_votes_;
45 
46  // Period data rlp without pillar votes
47  constexpr static size_t kBaseRlpItemCount = 4;
48 
49  // Period data rlp with pillar votes (optional since ficus hardfork)
50  constexpr static size_t kExtendedRlpItemCount = 5;
51 
56  bytes rlp() const;
57 
61  void clear();
62 };
63 std::ostream& operator<<(std::ostream& strm, PeriodData const& b);
64 
67 } // namespace taraxa
Definition: RLP.h:56
static bytes ToOldPeriodData(const bytes &rlp)
Definition: period_data.cpp:105
void clear()
Clear PBFT block, certify votes, DAG blocks, and transactions.
Definition: period_data.cpp:72
std::vector< std::shared_ptr< PbftVote > > previous_block_cert_votes
Definition: period_data.hpp:38
std::vector< DagBlock > dag_blocks
Definition: period_data.hpp:40
static PeriodData FromOldPeriodData(const dev::RLP &rlp)
Definition: period_data.cpp:80
SharedTransactions transactions
Definition: period_data.hpp:41
std::shared_ptr< PbftBlock > pbft_blk
Definition: period_data.hpp:37
PeriodData()=default
constexpr static size_t kBaseRlpItemCount
Definition: period_data.hpp:47
std::optional< std::vector< std::shared_ptr< PillarVote > > > pillar_votes_
Definition: period_data.hpp:44
constexpr static size_t kExtendedRlpItemCount
Definition: period_data.hpp:50
bytes rlp() const
Recursive Length Prefix.
Definition: period_data.cpp:42
PeriodData class is for block execution, that includes PBFT block, certify votes, DAG blocks,...
Definition: period_data.hpp:25
std::vector<::byte > bytes
Definition: Common.h:46
Definition: config.hpp:8
std::vector< SharedTransaction > SharedTransactions
Definition: transaction.hpp:81
std::ostream & operator<<(std::ostream &strm, NodeConfig const &conf)
Definition: config.cpp:205