| 109 | } |
| 110 | |
| 111 | bool BlockFilterIndex::Init() |
| 112 | { |
| 113 | if (!m_db->Read(DB_FILTER_POS, m_next_filter_pos)) { |
| 114 | // Check that the cause of the read failure is that the key does not exist. Any other errors |
| 115 | // indicate database corruption or a disk failure, and starting the index would cause |
| 116 | // further corruption. |
| 117 | if (m_db->Exists(DB_FILTER_POS)) { |
| 118 | return error("%s: Cannot read current %s state; index may be corrupted", |
| 119 | __func__, GetName()); |
| 120 | } |
| 121 | |
| 122 | // If the DB_FILTER_POS is not set, then initialize to the first location. |
| 123 | m_next_filter_pos.nFile = 0; |
| 124 | m_next_filter_pos.nPos = 0; |
| 125 | } |
| 126 | return BaseIndex::Init(); |
| 127 | } |
| 128 | |
| 129 | bool BlockFilterIndex::CommitInternal(CDBBatch& batch) |
| 130 | { |