| 134 | } |
| 135 | |
| 136 | bool BlockFilterIndex::CustomCommit(CDBBatch& batch) |
| 137 | { |
| 138 | const FlatFilePos& pos = m_next_filter_pos; |
| 139 | |
| 140 | // Flush current filter file to disk. |
| 141 | AutoFile file{m_filter_fileseq->Open(pos)}; |
| 142 | if (file.IsNull()) { |
| 143 | LogError("Failed to open filter file %d", pos.nFile); |
| 144 | return false; |
| 145 | } |
| 146 | if (!file.Commit()) { |
| 147 | LogError("Failed to commit filter file %d", pos.nFile); |
| 148 | (void)file.fclose(); |
| 149 | return false; |
| 150 | } |
| 151 | if (file.fclose() != 0) { |
| 152 | LogError("Failed to close filter file %d after commit: %s", pos.nFile, SysErrorString(errno)); |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | batch.Write(DB_FILTER_POS, pos); |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | bool BlockFilterIndex::ReadFilterFromDisk(const FlatFilePos& pos, const uint256& hash, BlockFilter& filter) const |
| 161 | { |