| 32 | } |
| 33 | |
| 34 | void 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 | |
| 62 | void AddressDB::addAddressNested(const blocksci::RawAddress &childAddress, const blocksci::DedupAddress &parentAddress) { |
| 63 | nestedCache.emplace_back(childAddress, parentAddress); |