mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Add dynamic federation blockheader fields to chaindb serialization
This commit is contained in:
parent
a74accf7d1
commit
4e52f2c83c
1 changed files with 34 additions and 2 deletions
36
src/chain.h
36
src/chain.h
|
|
@ -221,6 +221,9 @@ public:
|
|||
uint32_t nBits;
|
||||
uint32_t nNonce;
|
||||
CProof proof;
|
||||
// Dynamic federation fields
|
||||
DynaFedParams d_params;
|
||||
CScriptWitness m_signblock_witness;
|
||||
|
||||
//! (memory only) Sequential id assigned to distinguish order in which blocks are received.
|
||||
int32_t nSequenceId;
|
||||
|
|
@ -250,6 +253,8 @@ public:
|
|||
nBits = 0;
|
||||
nNonce = 0;
|
||||
proof.SetNull();
|
||||
d_params.SetNull();
|
||||
m_signblock_witness.SetNull();
|
||||
}
|
||||
|
||||
CBlockIndex()
|
||||
|
|
@ -267,6 +272,8 @@ public:
|
|||
nBits = block.nBits;
|
||||
nNonce = block.nNonce;
|
||||
proof = block.proof;
|
||||
d_params = block.m_dyna_params;
|
||||
m_signblock_witness = block.m_signblock_witness;
|
||||
}
|
||||
|
||||
CDiskBlockPos GetBlockPos() const {
|
||||
|
|
@ -301,6 +308,8 @@ public:
|
|||
block.nBits = nBits;
|
||||
block.nNonce = nNonce;
|
||||
block.proof = proof;
|
||||
block.m_dyna_params = d_params;
|
||||
block.m_signblock_witness = m_signblock_witness;
|
||||
return block;
|
||||
}
|
||||
|
||||
|
|
@ -423,13 +432,35 @@ public:
|
|||
READWRITE(VARINT(nUndoPos));
|
||||
|
||||
// block header
|
||||
READWRITE(this->nVersion);
|
||||
|
||||
// Detect dynamic federation block serialization using "HF bit",
|
||||
// or the signed bit which is invalid in Bitcoin
|
||||
bool is_dyna = false;
|
||||
int32_t nVersion;
|
||||
if (ser_action.ForRead()) {
|
||||
READWRITE(nVersion);
|
||||
is_dyna = nVersion < 0;
|
||||
this->nVersion = ~CBlockHeader::HF_MASK & nVersion;
|
||||
} else {
|
||||
nVersion = this->nVersion;
|
||||
if (!d_params.IsNull()) {
|
||||
nVersion |= CBlockHeader::HF_MASK;
|
||||
is_dyna = true;
|
||||
}
|
||||
READWRITE(nVersion);
|
||||
}
|
||||
|
||||
READWRITE(hashPrev);
|
||||
READWRITE(hashMerkleRoot);
|
||||
READWRITE(nTime);
|
||||
// For compatibility with elements 0.14 based chains
|
||||
if (g_signed_blocks) {
|
||||
READWRITE(proof);
|
||||
if (is_dyna) {
|
||||
READWRITE(d_params);
|
||||
READWRITE(m_signblock_witness.stack);
|
||||
} else {
|
||||
READWRITE(proof);
|
||||
}
|
||||
} else {
|
||||
READWRITE(nBits);
|
||||
READWRITE(nNonce);
|
||||
|
|
@ -449,6 +480,7 @@ public:
|
|||
block.nBits = nBits;
|
||||
block.nNonce = nNonce;
|
||||
block.proof = proof;
|
||||
block.m_dyna_params = d_params;
|
||||
return block.GetHash();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue