@@ -52,8 +52,8 @@ pub enum CheckBlockError<N: Network> {
5252 #[ error( "Block has invalid hash" ) ]
5353 InvalidHash ,
5454 /// An error related to the given prefix of pending blocks.
55- #[ error( "Prefix of the block at height {height} is incorrect - {error:?}" ) ]
56- InvalidPrefix { height : u32 , error : Box < CheckBlockError < N > > } ,
55+ #[ error( "The prefix as an error at index {index} - {error:?}" ) ]
56+ InvalidPrefix { index : usize , error : Box < CheckBlockError < N > > } ,
5757 #[ error( "The block contains solution '{solution_id}', but it already exists in the ledger" ) ]
5858 SolutionAlreadyExists { solution_id : SolutionID < N > } ,
5959 #[ error( "Failed to speculate over unconfirmed transactions - {inner}" ) ]
@@ -115,10 +115,10 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
115115 // First check that the heights and hashes of the pending block sequence and of the new block are correct.
116116 // The hash checks should be redundant, but we perform them out of extra caution.
117117 let mut expected_height = latest_block. height ( ) + 1 ;
118- for prefix_block in prefix {
118+ for ( index , prefix_block) in prefix. iter ( ) . enumerate ( ) {
119119 if prefix_block. height ( ) != expected_height {
120120 return Err ( CheckBlockError :: InvalidPrefix {
121- height : prefix_block . height ( ) ,
121+ index ,
122122 error : Box :: new ( CheckBlockError :: InvalidHeight {
123123 expected : expected_height,
124124 actual : prefix_block. height ( ) ,
@@ -128,7 +128,7 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
128128
129129 if self . contains_block_hash ( & prefix_block. hash ( ) ) ? {
130130 return Err ( CheckBlockError :: InvalidPrefix {
131- height : prefix_block . height ( ) ,
131+ index ,
132132 error : Box :: new ( CheckBlockError :: BlockAlreadyExists { hash : prefix_block. hash ( ) } ) ,
133133 } ) ;
134134 }
0 commit comments