@@ -1334,7 +1334,7 @@ impl CoreStore {
13341334 policy : & CorePipelinePolicy ,
13351335 ) -> Result < CoreManifestLocator > {
13361336 validate_logical_file_manifest_shape ( manifest) ?;
1337- let manifest_bytes = serde_json :: to_vec ( manifest) ?;
1337+ let manifest_bytes = encode_logical_file_manifest_bytes ( manifest) ?;
13381338 let manifest_hash = format ! ( "sha256:{}" , sha256_hex( & manifest_bytes) ) ;
13391339 let manifest_hash_hex = strip_sha256_prefix ( & manifest_hash) ?;
13401340 let profile = local_erasure_profile ( & policy. erasure_profile_id ) ?;
@@ -1586,7 +1586,7 @@ impl CoreStore {
15861586 {
15871587 bail ! ( "CoreStore manifest locator hash mismatch" ) ;
15881588 }
1589- let manifest: CoreLogicalFileManifest = serde_json :: from_slice ( & bytes) ?;
1589+ let manifest = decode_logical_file_manifest_bytes ( & bytes, & locator . manifest_encoding ) ?;
15901590 validate_logical_file_manifest_shape ( & manifest) ?;
15911591 if manifest. logical_file_id != locator. manifest_ref . logical_file_id
15921592 || manifest. writer_family != locator. manifest_ref . writer_family
@@ -6048,6 +6048,20 @@ fn object_ref_from_object_manifest(manifest: &CoreObjectManifest) -> Result<Core
60486048 } )
60496049}
60506050
6051+ fn encode_logical_file_manifest_bytes ( manifest : & CoreLogicalFileManifest ) -> Result < Vec < u8 > > {
6052+ encode_canonical_cbor_json ( & serde_json:: to_value ( manifest) ?)
6053+ }
6054+
6055+ fn decode_logical_file_manifest_bytes (
6056+ bytes : & [ u8 ] ,
6057+ manifest_encoding : & str ,
6058+ ) -> Result < CoreLogicalFileManifest > {
6059+ match manifest_encoding {
6060+ "canonical-cbor" => Ok ( serde_json:: from_value ( decode_canonical_cbor_json ( bytes) ?) ?) ,
6061+ other => bail ! ( "CoreStore unsupported logical file manifest encoding {other}" ) ,
6062+ }
6063+ }
6064+
60516065fn manifest_locator_from_manifest_and_ref (
60526066 manifest : & CoreLogicalFileManifest ,
60536067 manifest_object_ref : & CoreObjectRef ,
@@ -6068,7 +6082,7 @@ fn manifest_locator_from_manifest_and_ref(
60686082 writer_generation : manifest. writer_generation ,
60696083 manifest_hash : manifest_hash. to_string ( ) ,
60706084 } ,
6071- manifest_encoding : "writer-segment " . to_string ( ) ,
6085+ manifest_encoding : "canonical-cbor " . to_string ( ) ,
60726086 manifest_length : manifest_bytes_len,
60736087 manifest_hash : manifest_hash. to_string ( ) ,
60746088 block_locators,
@@ -9781,7 +9795,7 @@ mod tests {
97819795 write. locator. manifest_hash,
97829796 write. locator. manifest_ref. manifest_hash
97839797 ) ;
9784- assert_eq ! ( write. locator. manifest_encoding, "writer-segment " ) ;
9798+ assert_eq ! ( write. locator. manifest_encoding, "canonical-cbor " ) ;
97859799 assert_eq ! ( write. locator. block_locators. len( ) , 1 ) ;
97869800 let block = & write. locator . block_locators [ 0 ] ;
97879801 assert_eq ! ( block. logical_start, 0 ) ;
@@ -9901,7 +9915,7 @@ mod tests {
99019915 } )
99029916 . await
99039917 . unwrap ( ) ;
9904- let manifest_bytes = serde_json :: to_vec ( & write. manifest ) . unwrap ( ) ;
9918+ let manifest_bytes = encode_logical_file_manifest_bytes ( & write. manifest ) . unwrap ( ) ;
99059919 let split_at = manifest_bytes. len ( ) / 2 ;
99069920 let chunks = [ & manifest_bytes[ ..split_at] , & manifest_bytes[ split_at..] ] ;
99079921 let profile = local_erasure_profile ( LOCAL_ERASURE_PROFILE_ID ) . unwrap ( ) ;
0 commit comments