@@ -17,7 +17,11 @@ use tari_core::{
1717 base_node:: rpc:: { BaseNodeWalletQueryService , query_service} ,
1818 chain_storage:: BlockchainBackend ,
1919} ;
20- use tari_transaction_components:: rpc:: models:: { GetUtxosDeletedInfoRequest , GetUtxosDeletedInfoResponse } ;
20+ use tari_transaction_components:: rpc:: models:: {
21+ GetUtxosDeletedInfoRequest ,
22+ GetUtxosDeletedInfoResponse ,
23+ GetUtxosDeletedInfoResponseV1 ,
24+ } ;
2125use tari_utilities:: hex:: Hex ;
2226use tonic:: service:: AxumBody ;
2327
@@ -42,6 +46,8 @@ pub struct GetUtxosDeletedInfoParams {
4246 pub hashes : Vec < Vec < u8 > > ,
4347 #[ serde( deserialize_with = "from_hex" ) ]
4448 pub must_include_header : Vec < u8 > ,
49+ #[ serde( default ) ]
50+ pub version : u8 ,
4551}
4652
4753impl From < GetUtxosDeletedInfoParams > for GetUtxosDeletedInfoRequest {
@@ -59,7 +65,8 @@ impl From<GetUtxosDeletedInfoParams> for GetUtxosDeletedInfoRequest {
5965 params( GetUtxosDeletedInfoParams ) ,
6066 path = "/get_utxos_deleted_info" ,
6167 responses(
62- ( status = 200 , description = "UTXOs Deleted Info" , body = GetUtxosDeletedInfoResponse ) ,
68+ ( status = 200 , description = "UTXOs Deleted Info (v0)" , body = GetUtxosDeletedInfoResponse ) ,
69+ ( status = 200 , description = "UTXOs Deleted Info (v1, includes spent_timestamp)" , body = GetUtxosDeletedInfoResponseV1 ) ,
6370 ) ,
6471) ]
6572pub async fn handle < B : BlockchainBackend + ' static > (
@@ -68,15 +75,25 @@ pub async fn handle<B: BlockchainBackend + 'static>(
6875 Extension ( cache_cfg) : Extension < Arc < HttpCacheConfig > > ,
6976) -> Result < Response < AxumBody > , ( StatusCode , Json < ErrorResponse > ) > {
7077 debug ! ( target: LOG_TARGET , "Received get_utxos_deleted_info request: {params}" ) ;
78+ let version = params. version ;
7179 let request = params. into ( ) ;
7280
73- let response = query_service
74- . get_utxos_deleted_info ( request)
75- . await
76- . map_err ( error_handler_with_message) ?;
77-
78- let body = Json ( response) ;
79- let mut response = body. into_response ( ) ;
81+ let mut response = match version {
82+ 0 => {
83+ let result = query_service
84+ . get_utxos_deleted_info ( request)
85+ . await
86+ . map_err ( error_handler_with_message) ?;
87+ Json ( result) . into_response ( )
88+ } ,
89+ _ => {
90+ let result = query_service
91+ . get_utxos_deleted_info_v1 ( request)
92+ . await
93+ . map_err ( error_handler_with_message) ?;
94+ Json ( result) . into_response ( )
95+ } ,
96+ } ;
8097 apply_cache_control ( response. headers_mut ( ) , & cache_cfg, RouteKey :: GetUtxosDeletedInfo , 0 , 0 ) ;
8198 Ok ( response)
8299}
@@ -85,14 +102,15 @@ impl Display for GetUtxosDeletedInfoParams {
85102 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
86103 write ! (
87104 f,
88- "GetUtxosDeletedInfoParams {{ must_include_header: {}, hashes: {:?} }}" ,
105+ "GetUtxosDeletedInfoParams {{ must_include_header: {}, hashes: {:?}, version: {} }}" ,
89106 HashOutput :: try_from( self . must_include_header. as_slice( ) )
90107 . unwrap_or_default( )
91108 . to_hex( ) ,
92109 self . hashes
93110 . iter( )
94111 . map( |h| HashOutput :: try_from( h. as_slice( ) ) . unwrap_or_default( ) . to_hex( ) )
95- . collect:: <Vec <_>>( )
112+ . collect:: <Vec <_>>( ) ,
113+ self . version
96114 )
97115 }
98116}
0 commit comments