| 274 | } |
| 275 | |
| 276 | bool BaseIndex::Commit() |
| 277 | { |
| 278 | // Don't commit anything if we haven't indexed any block yet |
| 279 | // (this could happen if init is interrupted). |
| 280 | bool ok = m_best_block_index != nullptr; |
| 281 | if (ok) { |
| 282 | CDBBatch batch(GetDB()); |
| 283 | ok = CustomCommit(batch); |
| 284 | if (ok) { |
| 285 | GetDB().WriteBestBlock(batch, GetLocator(*m_chain, m_best_block_index.load()->GetBlockHash())); |
| 286 | GetDB().WriteBatch(batch); |
| 287 | } |
| 288 | } |
| 289 | if (!ok) { |
| 290 | LogError("Failed to commit latest %s state", GetName()); |
| 291 | return false; |
| 292 | } |
| 293 | return true; |
| 294 | } |
| 295 | |
| 296 | bool BaseIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_tip) |
| 297 | { |
no test coverage detected