| 279 | } |
| 280 | |
| 281 | bool BlockFilterIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_tip) |
| 282 | { |
| 283 | assert(current_tip->GetAncestor(new_tip->nHeight) == new_tip); |
| 284 | |
| 285 | CDBBatch batch(*m_db); |
| 286 | std::unique_ptr<CDBIterator> db_it(m_db->NewIterator()); |
| 287 | |
| 288 | // During a reorg, we need to copy all filters for blocks that are getting disconnected from the |
| 289 | // height index to the hash index so we can still find them when the height index entries are |
| 290 | // overwritten. |
| 291 | if (!CopyHeightIndexToHashIndex(*db_it, batch, m_name, new_tip->nHeight, current_tip->nHeight)) { |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | // The latest filter position gets written in Commit by the call to the BaseIndex::Rewind. |
| 296 | // But since this creates new references to the filter, the position should get updated here |
| 297 | // atomically as well in case Commit fails. |
| 298 | batch.Write(DB_FILTER_POS, m_next_filter_pos); |
| 299 | if (!m_db->WriteBatch(batch)) return false; |
| 300 | |
| 301 | return BaseIndex::Rewind(current_tip, new_tip); |
| 302 | } |
| 303 | |
| 304 | static bool LookupOne(const CDBWrapper& db, const CBlockIndex* block_index, DBVal& result) |
| 305 | { |
nothing calls this directly
no test coverage detected