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

Function ApplyHash

src/node/coinstats.cpp:52–70  ·  view source on GitHub ↗

Warning: be very careful when changing this! assumeutxo and UTXO snapshot validation commitments are reliant on the hash constructed by this function. If the construction of this hash is changed, it will invalidate existing UTXO snapshots. This will not result in any kind of consensus failure, but it will force clients that were expecting to make use of assumeutxo to do traditional IBD instead.

Source from the content-addressed store, hash-verified

50//! construction could cause a previously invalid (and potentially malicious)
51//! UTXO snapshot to be considered valid.
52static void ApplyHash(CHashWriter& ss, const uint256& hash, const std::map<uint32_t, Coin>& outputs)
53{
54 for (auto it = outputs.begin(); it != outputs.end(); ++it) {
55 if (it == outputs.begin()) {
56 ss << hash;
57 ss << VARINT(it->second.nHeight * 2 + it->second.fCoinBase ? 1u : 0u);
58 }
59
60 ss << VARINT(it->first + 1);
61 ss << it->second.out.scriptPubKey;
62 ss << it->second.out.nValue;
63 ss << it->second.out.nAsset;
64 ss << it->second.out.nNonce;
65
66 if (it == std::prev(outputs.end())) {
67 ss << VARINT(0u);
68 }
69 }
70}
71
72static void ApplyHash(std::nullptr_t, const uint256& hash, const std::map<uint32_t, Coin>& outputs) {}
73

Callers 1

GetUTXOStatsFunction · 0.85

Calls 6

MakeUCharSpanFunction · 0.85
TxOutSerFunction · 0.85
COutPointClass · 0.70
beginMethod · 0.45
endMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected