@@ -75,9 +75,7 @@ use walrus_core::{
7575 EncodingAxis ,
7676 EncodingConfig ,
7777 GeneralRecoverySymbol ,
78- Primary ,
7978 RecoverySymbolError ,
80- Secondary ,
8179 SliverData ,
8280 source_symbols_for_n_shards,
8381 } ,
@@ -3339,11 +3337,11 @@ impl StorageNodeInner {
33393337
33403338 let primary_index = symbol_id. primary_sliver_index ( ) ;
33413339 self . check_index ( primary_index) ?;
3342- let primary_pair_index = primary_index. to_pair_index :: < Primary > ( n_shards ) ;
3340+ let primary_pair_index = primary_index. to_pair_index ( n_shards , SliverType :: Primary ) ;
33433341
33443342 let secondary_index = symbol_id. secondary_sliver_index ( ) ;
33453343 self . check_index ( secondary_index) ?;
3346- let secondary_pair_index = secondary_index. to_pair_index :: < Secondary > ( n_shards ) ;
3344+ let secondary_pair_index = secondary_index. to_pair_index ( n_shards , SliverType :: Secondary ) ;
33473345
33483346 let owned_shards = self . owned_shards_at_latest_epoch ( ) ;
33493347
@@ -3480,11 +3478,12 @@ impl StorageNodeInner {
34803478 match * target_type {
34813479 SliverType :: Primary => SymbolId :: new (
34823480 * target,
3483- pair_stored. to_sliver_index :: < Secondary > ( n_shards) ,
3481+ pair_stored. to_sliver_index ( n_shards, SliverType :: Secondary ) ,
3482+ ) ,
3483+ SliverType :: Secondary => SymbolId :: new (
3484+ pair_stored. to_sliver_index ( n_shards, SliverType :: Primary ) ,
3485+ * target,
34843486 ) ,
3485- SliverType :: Secondary => {
3486- SymbolId :: new ( pair_stored. to_sliver_index :: < Primary > ( n_shards) , * target)
3487- }
34883487 }
34893488 } ;
34903489 Either :: Right ( self . owned_shards_at_latest_epoch ( ) . into_iter ( ) . map ( map_fn) )
@@ -3989,6 +3988,13 @@ impl ServiceState for StorageNodeInner {
39893988 intent : UploadIntent ,
39903989 ) -> Result < bool , StoreSliverError > {
39913990 self . check_index ( sliver_pair_index) ?;
3991+ let n_shards = self . n_shards ( ) ;
3992+ let sliver_index = sliver. sliver_index ( ) ;
3993+ ensure ! (
3994+ sliver_pair_index == sliver_index. to_pair_index( n_shards, sliver. r#type( ) ) ,
3995+ anyhow!( "sliver index mismatch" ) . into( )
3996+ ) ;
3997+
39923998 let ( metadata_persisted, persisted) = self
39933999 . resolve_metadata_for_sliver ( & blob_id, intent. is_pending ( ) )
39944000 . await ?;
@@ -8905,7 +8911,7 @@ mod tests {
89058911 ) ?;
89068912
89078913 let target_pair_index =
8908- target_sliver_index. to_pair_index :: < Primary > ( n_shards_nonzero ) ;
8914+ target_sliver_index. to_pair_index ( n_shards_nonzero , SliverType :: Primary ) ;
89098915 let expected_sliver = & blob_detail[ 0 ]
89108916 . pairs
89118917 . iter ( )
@@ -8932,7 +8938,7 @@ mod tests {
89328938 ) ?;
89338939
89348940 let target_pair_index =
8935- target_sliver_index. to_pair_index :: < Secondary > ( n_shards_nonzero ) ;
8941+ target_sliver_index. to_pair_index ( n_shards_nonzero , SliverType :: Secondary ) ;
89368942 let expected_sliver = & blob_detail[ 0 ]
89378943 . pairs
89388944 . iter ( )
0 commit comments