@@ -30,10 +30,6 @@ const INGRESS_TIMEOUT: Duration = Duration::from_secs(60 * 6);
3030/// from an 'execute_query' call.
3131const QUERY_TIMEOUT : Duration = Duration :: from_secs ( 30 ) ;
3232
33- /// Maximum time in seconds to wait for a result (successful or otherwise)
34- /// from an 'install_canister' call.
35- const INSTALL_TIMEOUT : Duration = INGRESS_TIMEOUT ;
36-
3733/// The HTTP path for query calls on the replica.
3834// TODO is this how v1 api works can we just change the URL?
3935pub fn query_path ( cid : CanisterId ) -> String {
@@ -207,9 +203,6 @@ pub struct Agent {
207203 // How long to wait for queries.
208204 query_timeout : Duration ,
209205
210- // How long to wait for `install_canister` requests.
211- pub ( crate ) install_timeout : Duration ,
212-
213206 // Per reqwest document, cloning a client does not clone the actual connection pool inside.
214207 // Therefore directly owning a client as opposed to a reference is the standard way to go.
215208 http_client : Arc < HttpClient > ,
@@ -227,7 +220,6 @@ impl fmt::Debug for Agent {
227220 . field ( "url" , & self . url )
228221 . field ( "ingress_timeout" , & self . ingress_timeout )
229222 . field ( "query_timeout" , & self . query_timeout )
230- . field ( "install_timeout" , & self . install_timeout )
231223 . field ( "sender" , & self . sender_field )
232224 . finish ( )
233225 }
@@ -267,7 +259,6 @@ impl Agent {
267259 url,
268260 ingress_timeout : INGRESS_TIMEOUT ,
269261 query_timeout : QUERY_TIMEOUT ,
270- install_timeout : INSTALL_TIMEOUT ,
271262 http_client,
272263 sender,
273264 sender_field,
@@ -286,12 +277,6 @@ impl Agent {
286277 self
287278 }
288279
289- /// Sets the timeout for canister installation.
290- pub fn with_install_timeout ( mut self , install_timeout : Duration ) -> Self {
291- self . install_timeout = install_timeout;
292- self
293- }
294-
295280 /// Queries the cup endpoint given the provided CatchUpPackageParams.
296281 pub async fn query_cup_endpoint (
297282 & self ,
@@ -367,26 +352,7 @@ impl Agent {
367352 arguments : Vec < u8 > ,
368353 nonce : Vec < u8 > ,
369354 ) -> Result < Option < Vec < u8 > > , String > {
370- self . execute_update_with_deadline (
371- canister_id,
372- method,
373- arguments,
374- nonce,
375- Instant :: now ( ) + self . ingress_timeout ,
376- )
377- . await
378- }
379-
380- /// Calls the query method 'method' on the canister located at 'url',
381- /// optionally with 'arguments'.
382- pub ( crate ) async fn execute_update_with_deadline < S : ToString > (
383- & self ,
384- canister_id : & CanisterId ,
385- method : S ,
386- arguments : Vec < u8 > ,
387- nonce : Vec < u8 > ,
388- deadline : Instant ,
389- ) -> Result < Option < Vec < u8 > > , String > {
355+ let deadline = Instant :: now ( ) + self . ingress_timeout ;
390356 let ( http_body, request_id) = self
391357 . prepare_update ( canister_id, method, arguments, nonce)
392358 . map_err ( |err| format ! ( "{}" , err) ) ?;
@@ -487,9 +453,7 @@ impl Agent {
487453 parse_read_state_response ( & request_id, cbor)
488454 }
489455
490- /// Requests the version of the public spec supported by this node by
491- /// querying /api/v1/status.
492- pub async fn ic_api_version ( & self ) -> Result < String , String > {
456+ async fn get_status_with_response ( & self ) -> Result < HttpStatusResponse , String > {
493457 let bytes = self
494458 . http_client
495459 . get_with_response (
@@ -499,43 +463,27 @@ impl Agent {
499463 )
500464 . await ?;
501465 let resp = bytes_to_cbor ( bytes) ?;
502- let response = serde_cbor:: value:: from_value :: < HttpStatusResponse > ( resp)
503- . map_err ( |source| format ! ( "decoding to HttpStatusResponse failed: {}" , source) ) ?;
466+ serde_cbor:: value:: from_value :: < HttpStatusResponse > ( resp)
467+ . map_err ( |source| format ! ( "decoding to HttpStatusResponse failed: {}" , source) )
468+ }
504469
470+ /// Requests the version of the public spec supported by this node by
471+ /// querying /api/v1/status.
472+ pub async fn ic_api_version ( & self ) -> Result < String , String > {
473+ let response = self . get_status_with_response ( ) . await ?;
505474 Ok ( response. ic_api_version )
506475 }
507476
508477 /// Requests the Replica impl version of this node by querying
509478 /// /api/v1/status
510479 pub async fn impl_version ( & self ) -> Result < Option < String > , String > {
511- let bytes = self
512- . http_client
513- . get_with_response (
514- & self . url ,
515- NODE_STATUS_PATH ,
516- tokio:: time:: Instant :: now ( ) + self . query_timeout ,
517- )
518- . await ?;
519- let resp = bytes_to_cbor ( bytes) ?;
520- let response = serde_cbor:: value:: from_value :: < HttpStatusResponse > ( resp)
521- . map_err ( |source| format ! ( "decoding to HttpStatusResponse failed: {}" , source) ) ?;
522-
480+ let response = self . get_status_with_response ( ) . await ?;
523481 Ok ( response. impl_version )
524482 }
525483
526484 /// Requests the root key of this node by querying /api/v1/status
527485 pub async fn root_key ( & self ) -> Result < Option < Blob > , String > {
528- let bytes = self
529- . http_client
530- . get_with_response (
531- & self . url ,
532- NODE_STATUS_PATH ,
533- tokio:: time:: Instant :: now ( ) + self . query_timeout ,
534- )
535- . await ?;
536- let resp = bytes_to_cbor ( bytes) ?;
537- let response = serde_cbor:: value:: from_value :: < HttpStatusResponse > ( resp)
538- . map_err ( |source| format ! ( "decoding to HttpStatusResponse failed: {}" , source) ) ?;
486+ let response = self . get_status_with_response ( ) . await ?;
539487
540488 Ok ( response. root_key )
541489 }
0 commit comments