1
1
use std:: { error:: Error , fmt:: Debug , hash:: Hash } ;
2
2
3
3
use axum:: {
4
+ body:: StreamBody ,
4
5
extract:: { Query , State } ,
5
- response:: Response ,
6
+ response:: { IntoResponse , Response } ,
6
7
Json ,
7
8
} ;
9
+ use http:: { header, StatusCode } ;
8
10
use nomos_api:: http:: { cl, consensus, da, libp2p, mempool, storage} ;
9
11
use nomos_core:: {
10
12
da:: {
11
- blob:: { info:: DispersedBlobInfo , metadata:: Metadata , Blob } ,
13
+ blob:: { info:: DispersedBlobInfo , metadata:: Metadata , Blob , LightBlob } ,
12
14
BlobId , DaVerifier as CoreDaVerifier ,
13
15
} ,
14
16
header:: HeaderId ,
15
17
tx:: Transaction ,
16
18
} ;
17
- use nomos_da_messages:: http:: da:: { DABlobCommitmentsRequest , DAGetLightBlobReq , GetRangeReq } ;
19
+ use nomos_da_messages:: http:: da:: {
20
+ DABlobCommitmentsRequest , DAGetLightBlobReq , GetRangeReq , GetSharesRequest ,
21
+ } ;
18
22
use nomos_da_network_core:: SubnetworkId ;
19
23
use nomos_da_sampling:: backend:: DaSamplingServiceBackend ;
20
24
use nomos_da_verifier:: backend:: VerifierBackend ;
@@ -254,7 +258,8 @@ where
254
258
B : Blob + Serialize + DeserializeOwned + Clone + Send + Sync + ' static ,
255
259
<B as Blob >:: BlobId : AsRef < [ u8 ] > + Send + Sync + ' static ,
256
260
<B as Blob >:: ColumnIndex : AsRef < [ u8 ] > + Send + Sync + ' static ,
257
- <B as Blob >:: LightBlob : Serialize + DeserializeOwned + Clone + Send + Sync + ' static ,
261
+ <B as Blob >:: LightBlob :
262
+ LightBlob + Serialize + DeserializeOwned + Clone + Send + Sync + ' static ,
258
263
<B as Blob >:: SharedCommitments : Serialize + DeserializeOwned + Clone + Send + Sync + ' static ,
259
264
M : MembershipHandler < NetworkId = SubnetworkId , Id = PeerId >
260
265
+ Clone
@@ -445,7 +450,7 @@ where
445
450
DaBlob : Blob ,
446
451
<DaBlob as Blob >:: BlobId : AsRef < [ u8 ] > + DeserializeOwned + Clone + Send + Sync + ' static ,
447
452
<DaBlob as Blob >:: ColumnIndex : AsRef < [ u8 ] > + DeserializeOwned + Send + Sync + ' static ,
448
- <DaBlob as Blob >:: LightBlob : Serialize + DeserializeOwned + Send + Sync + ' static ,
453
+ <DaBlob as Blob >:: LightBlob : LightBlob + Serialize + DeserializeOwned + Send + Sync + ' static ,
449
454
StorageOp : StorageSerde + Send + Sync + ' static ,
450
455
<StorageOp as StorageSerde >:: Error : Send + Sync ,
451
456
{
@@ -456,6 +461,50 @@ where
456
461
) )
457
462
}
458
463
464
+ #[ utoipa:: path(
465
+ get,
466
+ path = paths:: DA_GET_SHARES ,
467
+ responses(
468
+ ( status = 200 , description = "Request shares for a blob" , body = GetSharesRequest <DaBlob >) ,
469
+ ( status = 500 , description = "Internal server error" , body = StreamBody ) ,
470
+ )
471
+ ) ]
472
+ pub async fn da_get_shares < StorageOp , DaBlob > (
473
+ State ( handle) : State < OverwatchHandle > ,
474
+ Json ( request) : Json < GetSharesRequest < DaBlob > > ,
475
+ ) -> Response
476
+ where
477
+ DaBlob : Blob ,
478
+ <DaBlob as Blob >:: BlobId : AsRef < [ u8 ] > + DeserializeOwned + Clone + Send + Sync + ' static ,
479
+ <DaBlob as Blob >:: ColumnIndex : serde:: Serialize + DeserializeOwned + Send + Sync + Eq + Hash ,
480
+ <DaBlob as Blob >:: LightBlob : LightBlob < ColumnIndex = <DaBlob as Blob >:: ColumnIndex >
481
+ + Serialize
482
+ + DeserializeOwned
483
+ + Send
484
+ + Sync
485
+ + ' static ,
486
+ StorageOp : StorageSerde + Send + Sync + ' static ,
487
+ <StorageOp as StorageSerde >:: Error : Send + Sync ,
488
+ <DaBlob as Blob >:: LightBlob : LightBlob ,
489
+ <DaBlob as Blob >:: ColumnIndex : ' static ,
490
+ {
491
+ match storage:: get_shares :: < StorageOp , DaBlob > (
492
+ & handle,
493
+ request. blob_id ,
494
+ request. requested_shares ,
495
+ request. filter_shares ,
496
+ request. return_available ,
497
+ )
498
+ . await
499
+ {
500
+ Ok ( shares) => {
501
+ let body = StreamBody :: new ( shares) ;
502
+ IntoResponse :: into_response ( ( [ ( header:: CONTENT_TYPE , "application/x-ndjson" ) ] , body) )
503
+ }
504
+ Err ( e) => IntoResponse :: into_response ( ( StatusCode :: INTERNAL_SERVER_ERROR , e. to_string ( ) ) ) ,
505
+ }
506
+ }
507
+
459
508
#[ utoipa:: path(
460
509
post,
461
510
path = paths:: MEMPOOL_ADD_TX ,
0 commit comments