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:: {
9
11
cl, consensus,
10
12
da:: { self , PeerMessagesFactory } ,
11
13
libp2p, mempool, storage,
12
14
} ;
13
15
use nomos_core:: {
14
16
da:: {
15
- blob:: { info:: DispersedBlobInfo , metadata:: Metadata , Blob } ,
17
+ blob:: { info:: DispersedBlobInfo , metadata:: Metadata , Blob , LightBlob } ,
16
18
BlobId , DaVerifier as CoreDaVerifier ,
17
19
} ,
18
20
header:: HeaderId ,
19
21
tx:: Transaction ,
20
22
} ;
21
- use nomos_da_messages:: http:: da:: { DABlobCommitmentsRequest , DAGetLightBlobReq , GetRangeReq } ;
23
+ use nomos_da_messages:: http:: da:: {
24
+ DABlobCommitmentsRequest , DAGetLightBlobReq , GetRangeReq , GetSharesRequest ,
25
+ } ;
22
26
use nomos_da_network_core:: SubnetworkId ;
23
27
use nomos_da_network_service:: backends:: NetworkBackend ;
24
28
use nomos_da_sampling:: backend:: DaSamplingServiceBackend ;
@@ -259,7 +263,8 @@ where
259
263
B : Blob + Serialize + DeserializeOwned + Clone + Send + Sync + ' static ,
260
264
<B as Blob >:: BlobId : AsRef < [ u8 ] > + Send + Sync + ' static ,
261
265
<B as Blob >:: ColumnIndex : AsRef < [ u8 ] > + Send + Sync + ' static ,
262
- <B as Blob >:: LightBlob : Serialize + DeserializeOwned + Clone + Send + Sync + ' static ,
266
+ <B as Blob >:: LightBlob :
267
+ LightBlob + Serialize + DeserializeOwned + Clone + Send + Sync + ' static ,
263
268
<B as Blob >:: SharedCommitments : Serialize + DeserializeOwned + Clone + Send + Sync + ' static ,
264
269
M : MembershipHandler < NetworkId = SubnetworkId , Id = PeerId >
265
270
+ Clone
@@ -505,7 +510,7 @@ where
505
510
DaBlob : Blob ,
506
511
<DaBlob as Blob >:: BlobId : AsRef < [ u8 ] > + DeserializeOwned + Clone + Send + Sync + ' static ,
507
512
<DaBlob as Blob >:: ColumnIndex : AsRef < [ u8 ] > + DeserializeOwned + Send + Sync + ' static ,
508
- <DaBlob as Blob >:: LightBlob : Serialize + DeserializeOwned + Send + Sync + ' static ,
513
+ <DaBlob as Blob >:: LightBlob : LightBlob + Serialize + DeserializeOwned + Send + Sync + ' static ,
509
514
StorageOp : StorageSerde + Send + Sync + ' static ,
510
515
<StorageOp as StorageSerde >:: Error : Send + Sync ,
511
516
{
@@ -516,6 +521,50 @@ where
516
521
) )
517
522
}
518
523
524
+ #[ utoipa:: path(
525
+ get,
526
+ path = paths:: DA_GET_SHARES ,
527
+ responses(
528
+ ( status = 200 , description = "Request shares for a blob" , body = GetSharesRequest <DaBlob >) ,
529
+ ( status = 500 , description = "Internal server error" , body = StreamBody ) ,
530
+ )
531
+ ) ]
532
+ pub async fn da_get_shares < StorageOp , DaBlob > (
533
+ State ( handle) : State < OverwatchHandle > ,
534
+ Json ( request) : Json < GetSharesRequest < DaBlob > > ,
535
+ ) -> Response
536
+ where
537
+ DaBlob : Blob ,
538
+ <DaBlob as Blob >:: BlobId : AsRef < [ u8 ] > + DeserializeOwned + Clone + Send + Sync + ' static ,
539
+ <DaBlob as Blob >:: ColumnIndex : serde:: Serialize + DeserializeOwned + Send + Sync + Eq + Hash ,
540
+ <DaBlob as Blob >:: LightBlob : LightBlob < ColumnIndex = <DaBlob as Blob >:: ColumnIndex >
541
+ + Serialize
542
+ + DeserializeOwned
543
+ + Send
544
+ + Sync
545
+ + ' static ,
546
+ StorageOp : StorageSerde + Send + Sync + ' static ,
547
+ <StorageOp as StorageSerde >:: Error : Send + Sync ,
548
+ <DaBlob as Blob >:: LightBlob : LightBlob ,
549
+ <DaBlob as Blob >:: ColumnIndex : ' static ,
550
+ {
551
+ match storage:: get_shares :: < StorageOp , DaBlob > (
552
+ & handle,
553
+ request. blob_id ,
554
+ request. requested_shares ,
555
+ request. filter_shares ,
556
+ request. return_available ,
557
+ )
558
+ . await
559
+ {
560
+ Ok ( shares) => {
561
+ let body = StreamBody :: new ( shares) ;
562
+ IntoResponse :: into_response ( ( [ ( header:: CONTENT_TYPE , "application/x-ndjson" ) ] , body) )
563
+ }
564
+ Err ( e) => IntoResponse :: into_response ( ( StatusCode :: INTERNAL_SERVER_ERROR , e. to_string ( ) ) ) ,
565
+ }
566
+ }
567
+
519
568
#[ utoipa:: path(
520
569
post,
521
570
path = paths:: MEMPOOL_ADD_TX ,
0 commit comments