MCPcopy Create free account
hub / github.com/citp/BlockSci / load

Method load

tools/parser/preproccessed_block.cpp:73–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void RawTransaction::load(SafeMemReader &reader, uint32_t txNum_, blocksci::BlockHeight blockHeight_, bool witnessActivated) {
74 txNum = txNum_;
75 isSegwit = witnessActivated;
76 blockHeight = blockHeight_;
77 auto startOffset = reader.offset();
78 auto curOffset = reader.offset();
79 version = reader.readNext<decltype(version)>();
80 txHashStart = reader.unsafePos();
81 baseSize = static_cast<uint32_t>(reader.offset() - curOffset);
82 curOffset = reader.offset();
83 auto inputCount = reader.readVariableLengthInteger();
84 bool containsSegwit = false;
85 if (inputCount == 0) {
86 reader.readNext<uint8_t>(); // flag
87 //assert(flag == 1);
88 containsSegwit = true;
89 txHashStart = reader.unsafePos();
90 curOffset = reader.offset();
91 inputCount = reader.readVariableLengthInteger();
92 }
93 inputs.clear();
94 inputs.reserve(inputCount);
95 for (decltype(inputCount) i = 0; i < inputCount; i++) {
96 inputs.emplace_back(reader);
97 }
98
99 auto outputCount = reader.readVariableLengthInteger();
100
101 outputs.clear();
102 outputs.reserve(outputCount);
103 for (decltype(outputCount) i = 0; i < outputCount; i++) {
104 outputs.emplace_back(reader);
105 }
106 baseSize += static_cast<uint32_t>(reader.offset() - curOffset);
107 txHashLength = static_cast<uint32_t>(reader.unsafePos() - txHashStart);
108 if (containsSegwit) {
109 for (decltype(inputCount) i = 0; i < inputCount; i++) {
110 inputs[i].readWitnessStack(reader);
111 }
112 }
113 curOffset = reader.offset();
114 locktime = reader.readNext<Locktime>();
115 baseSize += static_cast<uint32_t>(reader.offset() - curOffset);
116 realSize = static_cast<uint32_t>(reader.offset() - startOffset);
117 hash.SetNull();
118}
119
120TransactionHeader::TransactionHeader(SafeMemReader &reader) {
121 auto startOffset = reader.offset();

Callers 3

nextTxImpMethod · 0.45
nextTxImpMethod · 0.45
json_dataFunction · 0.45

Calls 8

uint256SFunction · 0.85
offsetMethod · 0.80
unsafePosMethod · 0.80
readWitnessStackMethod · 0.80
clearMethod · 0.45
SetNullMethod · 0.45
sizeMethod · 0.45

Tested by 1

json_dataFunction · 0.36