@@ -120,10 +120,9 @@ impl<DB: Blockstore> ChainIndex<DB> {
120120
121121 /// Find tipset at epoch `to` in the chain of ancestors starting at `from`.
122122 ///
123- /// Returns [`None`] when the chain walk from `from` does not contain a
124- /// matching epoch (including when parent links are missing in the store).
125- /// Returns an error if `to` is greater than `from.epoch()`, or for
126- /// blockstore/genesis failures.
123+ /// On success, returns [`Some`] tipset wrapped in [`Ok`]. Returns an error if `to`
124+ /// is greater than `from.epoch()`, if the walk completes without resolving `to`
125+ /// (including when ancestor tipsets are missing), or for blockstore/genesis failures.
127126 ///
128127 /// # Why pass in the `from` argument?
129128 ///
@@ -228,7 +227,9 @@ impl<DB: Blockstore> ChainIndex<DB> {
228227 }
229228 }
230229 }
231- Ok ( None )
230+ Err ( Error :: Other ( format ! (
231+ "Tipset with epoch={to} does not exist"
232+ ) ) )
232233 }
233234
234235 /// Finds the latest beacon entry given a tipset up to 20 tipsets behind
@@ -358,7 +359,7 @@ mod tests {
358359 }
359360
360361 #[ test]
361- fn tipset_by_height_not_on_chain_returns_none ( ) {
362+ fn tipset_by_height_broken_ancestor_chain_returns_error ( ) {
362363 let db = Arc :: new ( MemoryDB :: default ( ) ) ;
363364 let genesis = genesis_tipset ( ) ;
364365 // Epoch 3 header points at a parent key we never persist — `Tipset::chain` stops
@@ -370,9 +371,8 @@ mod tests {
370371 let index = ChainIndex :: new ( db) ;
371372 assert ! (
372373 index
373- . tipset_by_height( 2 , epoch3. clone( ) , ResolveNullTipset :: TakeOlder )
374- . unwrap( )
375- . is_none( )
374+ . tipset_by_height( 2 , epoch3, ResolveNullTipset :: TakeOlder )
375+ . is_err( )
376376 ) ;
377377 }
378378}
0 commit comments