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

Method Unserialize

src/txdb.cpp:463–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461
462 template<typename Stream>
463 void Unserialize(Stream &s) {
464 unsigned int nCode = 0;
465 // version
466 unsigned int nVersionDummy;
467 ::Unserialize(s, VARINT(nVersionDummy));
468 // header code
469 ::Unserialize(s, VARINT(nCode));
470 fCoinBase = nCode & 1;
471 std::vector<bool> vAvail(2, false);
472 vAvail[0] = (nCode & 2) != 0;
473 vAvail[1] = (nCode & 4) != 0;
474 unsigned int nMaskCode = (nCode / 8) + ((nCode & 6) != 0 ? 0 : 1);
475 // spentness bitmask
476 while (nMaskCode > 0) {
477 unsigned char chAvail = 0;
478 ::Unserialize(s, chAvail);
479 for (unsigned int p = 0; p < 8; p++) {
480 bool f = (chAvail & (1 << p)) != 0;
481 vAvail.push_back(f);
482 }
483 if (chAvail != 0)
484 nMaskCode--;
485 }
486 // txouts themself
487 vout.assign(vAvail.size(), CTxOut());
488 for (unsigned int i = 0; i < vAvail.size(); i++) {
489 if (vAvail[i])
490 ::Unserialize(s, Using<TxOutCompression>(vout[i]));
491 }
492 // coinbase height
493 ::Unserialize(s, VARINT_MODE(nHeight, VarIntMode::NONNEGATIVE_SIGNED));
494 }
495};
496
497}

Callers

nothing calls this directly

Calls 5

UnserializeFunction · 0.85
CTxOutClass · 0.50
push_backMethod · 0.45
assignMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected