* Contains all the consensus parameters that can be voted for in dynamic federations */
| 57 | * Contains all the consensus parameters that can be voted for in dynamic federations |
| 58 | */ |
| 59 | class DynaFedParamEntry |
| 60 | { |
| 61 | public: |
| 62 | // Determines how these entries are serialized and stored |
| 63 | // 0 -> Null. Only used for proposed parameter "null votes" |
| 64 | // 1 -> Pruned. Doesn't have non-signblockscript data. That elided data |
| 65 | // is committed to in m_elided_root, and validated against chainstate. |
| 66 | // 2 -> Full. Typically only consensus-legal at epoch start. |
| 67 | unsigned char m_serialize_type{0}; |
| 68 | |
| 69 | CScript m_signblockscript{}; |
| 70 | uint32_t m_signblock_witness_limit{0}; // Max block signature witness serialized size |
| 71 | CScript m_fedpeg_program{}; // The "scriptPubKey" of the fedpegscript |
| 72 | CScript m_fedpegscript{}; // The witnessScript for witness v0 or undefined otherwise. |
| 73 | // No consensus meaning to the particular bytes, currently we interpret as PAK keys, details in pak.h |
| 74 | std::vector<std::vector<unsigned char>> m_extension_space{}; |
| 75 | uint256 m_elided_root{}; // non-zero only when m_serialize_type == 1 |
| 76 | |
| 77 | // Each constructor sets its own serialization type implicitly based on which |
| 78 | // arguments are given |
| 79 | DynaFedParamEntry() {}; |
| 80 | DynaFedParamEntry(const CScript& signblockscript_in, const uint32_t sbs_wit_limit_in, const uint256 elided_root_in) : m_signblockscript(signblockscript_in), m_signblock_witness_limit(sbs_wit_limit_in), m_elided_root(elided_root_in) { m_serialize_type = 1; }; |
| 81 | DynaFedParamEntry(const CScript& signblockscript_in, const uint32_t sbs_wit_limit_in, const CScript& fedpeg_program_in, const CScript& fedpegscript_in, const std::vector<std::vector<unsigned char>> extension_space_in) : m_signblockscript(signblockscript_in), m_signblock_witness_limit(sbs_wit_limit_in), m_fedpeg_program(fedpeg_program_in), m_fedpegscript(fedpegscript_in), m_extension_space(extension_space_in) { m_serialize_type = 2; }; |
| 82 | |
| 83 | template <typename Stream> |
| 84 | inline void Serialize(Stream& s) const { |
| 85 | s << m_serialize_type; |
| 86 | switch(m_serialize_type) { |
| 87 | case 0: |
| 88 | /* Null entry, used to signal "no vote" proposal */ |
| 89 | break; |
| 90 | case 1: |
| 91 | s << m_signblockscript; |
| 92 | s << m_signblock_witness_limit; |
| 93 | s << m_elided_root; |
| 94 | break; |
| 95 | case 2: |
| 96 | s << m_signblockscript; |
| 97 | s << m_signblock_witness_limit; |
| 98 | s << m_fedpeg_program; |
| 99 | s << m_fedpegscript; |
| 100 | s << m_extension_space; |
| 101 | break; |
| 102 | default: |
| 103 | assert(false && "Invalid consensus parameter entry type"); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | template <typename Stream> |
| 108 | inline void Unserialize(Stream& s) { |
| 109 | s >> m_serialize_type; |
| 110 | switch(m_serialize_type) { |
| 111 | case 0: |
| 112 | /* Null entry, used to signal "no vote" proposal */ |
| 113 | break; |
| 114 | case 1: |
| 115 | s >> m_signblockscript; |
| 116 | s >> m_signblock_witness_limit; |
no outgoing calls