mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +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 nBits;
|
||||||
uint32_t nNonce;
|
uint32_t nNonce;
|
||||||
CProof proof;
|
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.
|
//! (memory only) Sequential id assigned to distinguish order in which blocks are received.
|
||||||
int32_t nSequenceId;
|
int32_t nSequenceId;
|
||||||
|
|
@ -250,6 +253,8 @@ public:
|
||||||
nBits = 0;
|
nBits = 0;
|
||||||
nNonce = 0;
|
nNonce = 0;
|
||||||
proof.SetNull();
|
proof.SetNull();
|
||||||
|
d_params.SetNull();
|
||||||
|
m_signblock_witness.SetNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
CBlockIndex()
|
CBlockIndex()
|
||||||
|
|
@ -267,6 +272,8 @@ public:
|
||||||
nBits = block.nBits;
|
nBits = block.nBits;
|
||||||
nNonce = block.nNonce;
|
nNonce = block.nNonce;
|
||||||
proof = block.proof;
|
proof = block.proof;
|
||||||
|
d_params = block.m_dyna_params;
|
||||||
|
m_signblock_witness = block.m_signblock_witness;
|
||||||
}
|
}
|
||||||
|
|
||||||
CDiskBlockPos GetBlockPos() const {
|
CDiskBlockPos GetBlockPos() const {
|
||||||
|
|
@ -301,6 +308,8 @@ public:
|
||||||
block.nBits = nBits;
|
block.nBits = nBits;
|
||||||
block.nNonce = nNonce;
|
block.nNonce = nNonce;
|
||||||
block.proof = proof;
|
block.proof = proof;
|
||||||
|
block.m_dyna_params = d_params;
|
||||||
|
block.m_signblock_witness = m_signblock_witness;
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -423,13 +432,35 @@ public:
|
||||||
READWRITE(VARINT(nUndoPos));
|
READWRITE(VARINT(nUndoPos));
|
||||||
|
|
||||||
// block header
|
// 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(hashPrev);
|
||||||
READWRITE(hashMerkleRoot);
|
READWRITE(hashMerkleRoot);
|
||||||
READWRITE(nTime);
|
READWRITE(nTime);
|
||||||
// For compatibility with elements 0.14 based chains
|
// For compatibility with elements 0.14 based chains
|
||||||
if (g_signed_blocks) {
|
if (g_signed_blocks) {
|
||||||
READWRITE(proof);
|
if (is_dyna) {
|
||||||
|
READWRITE(d_params);
|
||||||
|
READWRITE(m_signblock_witness.stack);
|
||||||
|
} else {
|
||||||
|
READWRITE(proof);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
READWRITE(nBits);
|
READWRITE(nBits);
|
||||||
READWRITE(nNonce);
|
READWRITE(nNonce);
|
||||||
|
|
@ -449,6 +480,7 @@ public:
|
||||||
block.nBits = nBits;
|
block.nBits = nBits;
|
||||||
block.nNonce = nNonce;
|
block.nNonce = nNonce;
|
||||||
block.proof = proof;
|
block.proof = proof;
|
||||||
|
block.m_dyna_params = d_params;
|
||||||
return block.GetHash();
|
return block.GetHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue