MCPcopy Create free account
hub / github.com/ElementsProject/elements / Serialize

Method Serialize

src/primitives/block.h:240–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238
239 template <typename Stream>
240 inline void Serialize(Stream& s) const {
241 const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);
242
243 // Detect dynamic federation block serialization using "HF bit",
244 // or the signed bit which is invalid in Bitcoin
245 bool is_dyna = false;
246 int32_t nVersion = this->nVersion;
247 if (!m_dynafed_params.IsNull()) {
248 nVersion |= DYNAFED_HF_MASK;
249 is_dyna = true;
250 }
251 s << (nVersion);
252
253 if (is_dyna) {
254 s << hashPrevBlock;
255 s << hashMerkleRoot;
256 s << nTime;
257 s << block_height;
258 s << m_dynafed_params;
259 // We do not serialize witness for hashes, or weight calculation
260 if (!(s.GetType() & SER_GETHASH) && fAllowWitness) {
261 s << m_signblock_witness.stack;
262 }
263 } else {
264 s << hashPrevBlock;
265 s << hashMerkleRoot;
266 s << nTime;
267 if (g_con_blockheightinheader) {
268 s << block_height;
269 }
270 if (g_signed_blocks) {
271 s << proof;
272 } else {
273 s << nBits;
274 s << nNonce;
275 }
276 }
277 }
278
279 template <typename Stream>
280 inline void Unserialize(Stream& s) {

Callers

nothing calls this directly

Calls 3

GetVersionMethod · 0.45
IsNullMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected