mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Allow untrimming headers when needed
This commit is contained in:
parent
4259278ff5
commit
c28c5ce619
5 changed files with 40 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include <dynafed.h>
|
||||
#include <hash.h>
|
||||
#include <validation.h>
|
||||
|
||||
bool NextBlockIsParameterTransition(const CBlockIndex* pindexPrev, const Consensus::Params& consensus, DynaFedParamEntry& winning_entry)
|
||||
{
|
||||
|
|
@ -15,6 +16,7 @@ bool NextBlockIsParameterTransition(const CBlockIndex* pindexPrev, const Consens
|
|||
for (int32_t height = next_height - 1; height >= (int32_t)(next_height - consensus.dynamic_epoch_length); --height) {
|
||||
const CBlockIndex* p_epoch_walk = pindexPrev->GetAncestor(height);
|
||||
assert(p_epoch_walk);
|
||||
ForceUntrimHeader(p_epoch_walk);
|
||||
const DynaFedParamEntry& proposal = p_epoch_walk->dynafed_params().m_proposed;
|
||||
const uint256 proposal_root = proposal.CalculateRoot();
|
||||
vote_tally[proposal_root]++;
|
||||
|
|
@ -60,6 +62,7 @@ DynaFedParamEntry ComputeNextBlockFullCurrentParameters(const CBlockIndex* pinde
|
|||
// may be pre-dynafed params
|
||||
const CBlockIndex* p_epoch_start = pindexPrev->GetAncestor(epoch_start_height);
|
||||
assert(p_epoch_start);
|
||||
ForceUntrimHeader(p_epoch_start);
|
||||
if (p_epoch_start->dynafed_params().IsNull()) {
|
||||
// We need to construct the "full" current parameters of pre-dynafed
|
||||
// consensus
|
||||
|
|
@ -93,6 +96,7 @@ DynaFedParamEntry ComputeNextBlockCurrentParameters(const CBlockIndex* pindexPre
|
|||
{
|
||||
assert(pindexPrev);
|
||||
|
||||
ForceUntrimHeader(pindexPrev);
|
||||
DynaFedParamEntry entry = ComputeNextBlockFullCurrentParameters(pindexPrev, consensus);
|
||||
|
||||
uint32_t next_height = pindexPrev->nHeight+1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue