Skip to content

Commit 331f044

Browse files
committed
index: blockfilter, decouple Write into its own function
1 parent bcbd7eb commit 331f044

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/index/blockfilterindex.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,16 +252,21 @@ bool BlockFilterIndex::CustomAppend(const interfaces::BlockInfo& block)
252252

253253
BlockFilter filter(m_filter_type, *Assert(block.data), block_undo);
254254

255+
return Write(filter, block.height, filter.ComputeHeader(prev_header));
256+
}
257+
258+
bool BlockFilterIndex::Write(const BlockFilter& filter, uint32_t block_height, const uint256& filter_header)
259+
{
255260
size_t bytes_written = WriteFilterToDisk(m_next_filter_pos, filter);
256261
if (bytes_written == 0) return false;
257262

258263
std::pair<uint256, DBVal> value;
259-
value.first = block.hash;
264+
value.first = filter.GetBlockHash();
260265
value.second.hash = filter.GetHash();
261-
value.second.header = filter.ComputeHeader(prev_header);
266+
value.second.header = filter_header;
262267
value.second.pos = m_next_filter_pos;
263268

264-
if (!m_db->Write(DBHeightKey(block.height), value)) {
269+
if (!m_db->Write(DBHeightKey(block_height), value)) {
265270
return false;
266271
}
267272

src/index/blockfilterindex.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class BlockFilterIndex final : public BaseIndex
4444

4545
bool AllowPrune() const override { return true; }
4646

47+
bool Write(const BlockFilter& filter, uint32_t block_height, const uint256& filter_header);
48+
4749
protected:
4850
bool CustomInit(const std::optional<interfaces::BlockKey>& block) override;
4951

0 commit comments

Comments
 (0)