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

Method processTx

tools/parser/address_db.cpp:34–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34void AddressDB::processTx(const blocksci::RawTransaction *tx, uint32_t txNum, const blocksci::ChainAccess &, const blocksci::ScriptAccess &scripts) {
35 std::unordered_set<RawAddress> addedAddresses;
36 std::function<bool(const RawAddress &)> visitFunc = [&](const RawAddress &a) {
37 if (dedupType(a.type) == DedupAddressType::SCRIPTHASH && addedAddresses.find(a) == addedAddresses.end()) {
38 addedAddresses.insert(a);
39 auto scriptHash = scripts.getScriptData<DedupAddressType::SCRIPTHASH>(a.scriptNum);
40 if (scriptHash->txFirstSpent == txNum) {
41 addAddressNested(scriptHash->wrappedAddress, DedupAddress{a.scriptNum, DedupAddressType::SCRIPTHASH});
42 return true;
43 } else {
44 return false;
45 }
46 } else {
47 return false;
48 }
49 };
50 auto inputs = ranges::make_subrange(tx->beginInputs(), tx->endInputs());
51 for (auto &input : inputs) {
52 visit(RawAddress{input.getAddressNum(), input.getType()}, visitFunc, scripts);
53 }
54
55 for (uint16_t i = 0; i < tx->outputCount; i++) {
56 auto &output = tx->getOutput(i);
57 auto pointer = InoutPointer{txNum, i};
58 addAddressOutput(blocksci::RawAddress{output.getAddressNum(), output.getType()}, pointer);
59 }
60}
61
62void AddressDB::addAddressNested(const blocksci::RawAddress &childAddress, const blocksci::DedupAddress &parentAddress) {
63 nestedCache.emplace_back(childAddress, parentAddress);

Callers 1

runUpdateMethod · 0.45

Calls 5

dedupTypeFunction · 0.85
insertMethod · 0.80
visitFunction · 0.70
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected