@@ -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+ LogError (" %s: Cannot read current %s state; index may be corrupted\n " ,
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+ LogError (" %s: Failed to open filter file %d\n " , __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+ LogError (" %s: Failed to commit filter file %d\n " , __func__, pos.nFile );
146+ return false ;
144147 }
145148
146149 batch.Write (DB_FILTER_POS, pos);
@@ -159,11 +162,15 @@ bool BlockFilterIndex::ReadFilterFromDisk(const FlatFilePos& pos, const uint256&
159162 std::vector<uint8_t > encoded_filter;
160163 try {
161164 filein >> block_hash >> encoded_filter;
162- if (Hash (encoded_filter) != hash) return error (" Checksum mismatch in filter decode." );
165+ if (Hash (encoded_filter) != hash) {
166+ LogError (" Checksum mismatch in filter decode.\n " );
167+ return false ;
168+ }
163169 filter = BlockFilter (GetFilterType (), block_hash, std::move (encoded_filter), /* skip_decode_check=*/ true );
164170 }
165171 catch (const std::exception& e) {
166- return error (" %s: Failed to deserialize block filter from disk: %s" , __func__, e.what ());
172+ LogError (" %s: Failed to deserialize block filter from disk: %s\n " , __func__, e.what ());
173+ return false ;
167174 }
168175
169176 return true ;
@@ -235,8 +242,9 @@ bool BlockFilterIndex::CustomAppend(const interfaces::BlockInfo& block)
235242
236243 uint256 expected_block_hash = *Assert (block.prev_hash );
237244 if (read_out.first != expected_block_hash) {
238- return error (" %s: previous block header belongs to unexpected block %s; expected %s" ,
245+ LogError (" %s: previous block header belongs to unexpected block %s; expected %s\n " ,
239246 __func__, read_out.first .ToString (), expected_block_hash.ToString ());
247+ return false ;
240248 }
241249
242250 prev_header = read_out.second .header ;
@@ -270,14 +278,16 @@ bool BlockFilterIndex::CustomAppend(const interfaces::BlockInfo& block)
270278
271279 for (int height = start_height; height <= stop_height; ++height) {
272280 if (!db_it.GetKey (key) || key.height != height) {
273- return error (" %s: unexpected key in %s: expected (%c, %d)" ,
281+ LogError (" %s: unexpected key in %s: expected (%c, %d)\n " ,
274282 __func__, index_name, DB_BLOCK_HEIGHT, height);
283+ return false ;
275284 }
276285
277286 std::pair<uint256, DBVal> value;
278287 if (!db_it.GetValue (value)) {
279- return error (" %s: unable to read value in %s at key (%c, %d)" ,
288+ LogError (" %s: unable to read value in %s at key (%c, %d)\n " ,
280289 __func__, index_name, DB_BLOCK_HEIGHT, height);
290+ return false ;
281291 }
282292
283293 batch.Write (DBHashKey (value.first ), std::move (value.second ));
@@ -330,11 +340,13 @@ static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start
330340 const CBlockIndex* stop_index, std::vector<DBVal>& results)
331341{
332342 if (start_height < 0 ) {
333- return error (" %s: start height (%d) is negative" , __func__, start_height);
343+ LogError (" %s: start height (%d) is negative\n " , __func__, start_height);
344+ return false ;
334345 }
335346 if (start_height > stop_index->nHeight ) {
336- return error (" %s: start height (%d) is greater than stop height (%d)" ,
347+ LogError (" %s: start height (%d) is greater than stop height (%d)\n " ,
337348 __func__, start_height, stop_index->nHeight );
349+ return false ;
338350 }
339351
340352 size_t results_size = static_cast <size_t >(stop_index->nHeight - start_height + 1 );
@@ -350,8 +362,9 @@ static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start
350362
351363 size_t i = static_cast <size_t >(height - start_height);
352364 if (!db_it->GetValue (values[i])) {
353- return error (" %s: unable to read value in %s at key (%c, %d)" ,
365+ LogError (" %s: unable to read value in %s at key (%c, %d)\n " ,
354366 __func__, index_name, DB_BLOCK_HEIGHT, height);
367+ return false ;
355368 }
356369
357370 db_it->Next ();
@@ -373,8 +386,9 @@ static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start
373386 }
374387
375388 if (!db.Read (DBHashKey (block_hash), results[i])) {
376- return error (" %s: unable to read value in %s at key (%c, %s)" ,
389+ LogError (" %s: unable to read value in %s at key (%c, %s)\n " ,
377390 __func__, index_name, DB_BLOCK_HASH, block_hash.ToString ());
391+ return false ;
378392 }
379393 }
380394
0 commit comments