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

Method ReadFilterFromDisk

src/index/blockfilterindex.cpp:160–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160bool BlockFilterIndex::ReadFilterFromDisk(const FlatFilePos& pos, const uint256& hash, BlockFilter& filter) const
161{
162 AutoFile filein{m_filter_fileseq->Open(pos, true)};
163 if (filein.IsNull()) {
164 return false;
165 }
166
167 // Check that the hash of the encoded_filter matches the one stored in the db.
168 uint256 block_hash;
169 std::vector<uint8_t> encoded_filter;
170 try {
171 filein >> block_hash >> encoded_filter;
172 if (Hash(encoded_filter) != hash) {
173 LogError("Checksum mismatch in filter decode.");
174 return false;
175 }
176 filter = BlockFilter(GetFilterType(), block_hash, std::move(encoded_filter), /*skip_decode_check=*/true);
177 }
178 catch (const std::exception& e) {
179 LogError("Failed to deserialize block filter from disk: %s", e.what());
180 return false;
181 }
182
183 return true;
184}
185
186size_t BlockFilterIndex::WriteFilterToDisk(FlatFilePos& pos, const BlockFilter& filter)
187{

Callers

nothing calls this directly

Calls 5

BlockFilterClass · 0.70
HashFunction · 0.50
OpenMethod · 0.45
IsNullMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected