TODO cache this in CBlockIndex itself?
| 100 | |
| 101 | // TODO cache this in CBlockIndex itself? |
| 102 | DynaFedParamEntry ComputeNextBlockCurrentParameters(const CBlockIndex* pindexPrev, const Consensus::Params& consensus) |
| 103 | { |
| 104 | assert(pindexPrev); |
| 105 | |
| 106 | if (node::fTrimHeaders) { |
| 107 | LOCK(cs_main); |
| 108 | ForceUntrimHeader(pindexPrev); |
| 109 | } |
| 110 | DynaFedParamEntry entry = ComputeNextBlockFullCurrentParameters(pindexPrev, consensus); |
| 111 | |
| 112 | uint32_t next_height = pindexPrev->nHeight+1; |
| 113 | const uint32_t epoch_length = consensus.dynamic_epoch_length; |
| 114 | uint32_t epoch_age = next_height % epoch_length; |
| 115 | |
| 116 | // Return appropriate format based on epoch age or if we *just* activated |
| 117 | // dynafed via BIP9 |
| 118 | if (epoch_age == 0 || pindexPrev->dynafed_params().IsNull()) { |
| 119 | return entry; |
| 120 | } else { |
| 121 | return DynaFedParamEntry(entry.m_signblockscript, entry.m_signblock_witness_limit, entry.CalculateExtraRoot()); |
| 122 | |
| 123 | } |
| 124 | } |
| 125 |
no test coverage detected