@@ -119,8 +119,9 @@ bool BlockFilterIndex::CustomInit(const std::optional<interfaces::BlockKey>& blo
119119 // indicate database corruption or a disk failure, and starting the index would cause
120120 // further corruption.
121121 if (m_db->Exists (DB_FILTER_POS)) {
122- return error (" %s: Cannot read current %s state; index may be corrupted" ,
122+ error (" %s: Cannot read current %s state; index may be corrupted" ,
123123 __func__, GetName ());
124+ return false ;
124125 }
125126
126127 // If the DB_FILTER_POS is not set, then initialize to the first location.
@@ -137,10 +138,12 @@ bool BlockFilterIndex::CustomCommit(CDBBatch& batch)
137138 // Flush current filter file to disk.
138139 AutoFile file{m_filter_fileseq->Open (pos)};
139140 if (file.IsNull ()) {
140- return error (" %s: Failed to open filter file %d" , __func__, pos.nFile );
141+ error (" %s: Failed to open filter file %d" , __func__, pos.nFile );
142+ return false ;
141143 }
142144 if (!FileCommit (file.Get ())) {
143- return error (" %s: Failed to commit filter file %d" , __func__, pos.nFile );
145+ error (" %s: Failed to commit filter file %d" , __func__, pos.nFile );
146+ return false ;
144147 }
145148
146149 batch.Write (DB_FILTER_POS, pos);
@@ -160,12 +163,14 @@ bool BlockFilterIndex::ReadFilterFromDisk(const FlatFilePos& pos, const uint256&
160163 try {
161164 filein >> block_hash >> encoded_filter;
162165 if (Hash (encoded_filter) != hash) {
163- return error (" Checksum mismatch in filter decode." );
166+ error (" Checksum mismatch in filter decode." );
167+ return false ;
164168 }
165169 filter = BlockFilter (GetFilterType (), block_hash, std::move (encoded_filter), /* skip_decode_check=*/ true );
166170 }
167171 catch (const std::exception& e) {
168- return error (" %s: Failed to deserialize block filter from disk: %s" , __func__, e.what ());
172+ error (" %s: Failed to deserialize block filter from disk: %s" , __func__, e.what ());
173+ return false ;
169174 }
170175
171176 return true ;
@@ -237,8 +242,9 @@ bool BlockFilterIndex::CustomAppend(const interfaces::BlockInfo& block)
237242
238243 uint256 expected_block_hash = *Assert (block.prev_hash );
239244 if (read_out.first != expected_block_hash) {
240- return error (" %s: previous block header belongs to unexpected block %s; expected %s" ,
245+ error (" %s: previous block header belongs to unexpected block %s; expected %s" ,
241246 __func__, read_out.first .ToString (), expected_block_hash.ToString ());
247+ return false ;
242248 }
243249
244250 prev_header = read_out.second .header ;
@@ -272,14 +278,16 @@ bool BlockFilterIndex::CustomAppend(const interfaces::BlockInfo& block)
272278
273279 for (int height = start_height; height <= stop_height; ++height) {
274280 if (!db_it.GetKey (key) || key.height != height) {
275- return error (" %s: unexpected key in %s: expected (%c, %d)" ,
281+ error (" %s: unexpected key in %s: expected (%c, %d)" ,
276282 __func__, index_name, DB_BLOCK_HEIGHT, height);
283+ return false ;
277284 }
278285
279286 std::pair<uint256, DBVal> value;
280287 if (!db_it.GetValue (value)) {
281- return error (" %s: unable to read value in %s at key (%c, %d)" ,
288+ error (" %s: unable to read value in %s at key (%c, %d)" ,
282289 __func__, index_name, DB_BLOCK_HEIGHT, height);
290+ return false ;
283291 }
284292
285293 batch.Write (DBHashKey (value.first ), std::move (value.second ));
@@ -332,11 +340,13 @@ static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start
332340 const CBlockIndex* stop_index, std::vector<DBVal>& results)
333341{
334342 if (start_height < 0 ) {
335- return error (" %s: start height (%d) is negative" , __func__, start_height);
343+ error (" %s: start height (%d) is negative" , __func__, start_height);
344+ return false ;
336345 }
337346 if (start_height > stop_index->nHeight ) {
338- return error (" %s: start height (%d) is greater than stop height (%d)" ,
347+ error (" %s: start height (%d) is greater than stop height (%d)" ,
339348 __func__, start_height, stop_index->nHeight );
349+ return false ;
340350 }
341351
342352 size_t results_size = static_cast <size_t >(stop_index->nHeight - start_height + 1 );
@@ -352,8 +362,9 @@ static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start
352362
353363 size_t i = static_cast <size_t >(height - start_height);
354364 if (!db_it->GetValue (values[i])) {
355- return error (" %s: unable to read value in %s at key (%c, %d)" ,
365+ error (" %s: unable to read value in %s at key (%c, %d)" ,
356366 __func__, index_name, DB_BLOCK_HEIGHT, height);
367+ return false ;
357368 }
358369
359370 db_it->Next ();
@@ -375,8 +386,9 @@ static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start
375386 }
376387
377388 if (!db.Read (DBHashKey (block_hash), results[i])) {
378- return error (" %s: unable to read value in %s at key (%c, %s)" ,
389+ error (" %s: unable to read value in %s at key (%c, %s)" ,
379390 __func__, index_name, DB_BLOCK_HASH, block_hash.ToString ());
391+ return false ;
380392 }
381393 }
382394
0 commit comments