MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / DeserializeDB

Function DeserializeDB

src/addrdb.cpp:100–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98
99template <typename Stream, typename Data>
100void DeserializeDB(Stream& stream, Data&& data, bool fCheckSum = true)
101{
102 HashVerifier verifier{stream};
103 // de-serialize file header (network specific magic number) and ..
104 MessageStartChars pchMsgTmp;
105 verifier >> pchMsgTmp;
106 // ... verify the network matches ours
107 if (pchMsgTmp != Params().MessageStart()) {
108 throw std::runtime_error{"Invalid network magic number"};
109 }
110
111 // de-serialize data
112 verifier >> data;
113
114 // verify checksum
115 if (fCheckSum) {
116 uint256 hashTmp;
117 stream >> hashTmp;
118 if (hashTmp != verifier.GetHash()) {
119 throw std::runtime_error{"Checksum mismatch, data corrupted"};
120 }
121 }
122}
123
124template <typename Data>
125void DeserializeFileDB(const fs::path& path, Data&& data)

Callers 2

DeserializeFileDBFunction · 0.85
ReadFromStreamFunction · 0.85

Calls 2

ParamsClass · 0.70
GetHashMethod · 0.45

Tested by

no test coverage detected