File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed
packages/agent_dart_base/lib Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,13 @@ Future<T> withRetry<T>(
39
39
}
40
40
}
41
41
42
+ /// Most of the timeouts will happen in 5 minutes.
43
+ const defaultExpireInMinutes = 5 ;
44
+ const defaultExpireInDuration = Duration (minutes: defaultExpireInMinutes);
45
+
42
46
/// Default delta for ingress expiry is 5 minutes.
43
- const _defaultIngressExpiryDeltaInMilliseconds = 5 * 60 * 1000 ;
47
+ const _defaultIngressExpiryDeltaInMilliseconds =
48
+ defaultExpireInMinutes * 60 * 1000 ;
44
49
45
50
/// Root public key for the IC, encoded as hex
46
51
const _icRootKey = '308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7'
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ PollStrategy defaultStrategy() {
19
19
return chain ([
20
20
conditionalDelay (once (), 1000 ),
21
21
backoff (1000 , 1.2 ),
22
- timeout (5 * 60 * 1000 ),
22
+ timeout (defaultExpireInDuration ),
23
23
]);
24
24
}
25
25
@@ -84,19 +84,19 @@ PollStrategy throttlePolling(int throttleMilliseconds) {
84
84
};
85
85
}
86
86
87
- PollStrategy timeout (int milliseconds ) {
88
- final end = DateTime .now ().millisecondsSinceEpoch + milliseconds ;
87
+ PollStrategy timeout (Duration duration ) {
88
+ final end = DateTime .now ().add (duration) ;
89
89
return (
90
90
Principal canisterId,
91
91
RequestId requestId,
92
92
RequestStatusResponseStatus status,
93
93
) async {
94
- if (DateTime .now ().millisecondsSinceEpoch > end) {
94
+ if (DateTime .now ().isAfter ( end) ) {
95
95
throw TimeoutException (
96
- 'Request timed out after $milliseconds milliseconds :\n '
96
+ 'Request timed out after $duration :\n '
97
97
' Request ID: ${requestIdToHex (requestId )}\n '
98
98
' Request status: $status \n ' ,
99
- Duration (milliseconds : milliseconds) ,
99
+ duration ,
100
100
);
101
101
}
102
102
};
Original file line number Diff line number Diff line change @@ -164,9 +164,7 @@ class DelegationChain {
164
164
DelegationChain ? previous,
165
165
List <Principal >? targets,
166
166
}) async {
167
- expiration ?? = DateTime .fromMillisecondsSinceEpoch (
168
- DateTime .now ().millisecondsSinceEpoch + 15 * 60 * 1000 ,
169
- );
167
+ expiration ?? = DateTime .now ().add (const Duration (minutes: 15 ));
170
168
final delegation = await _createSingleDelegation (
171
169
from,
172
170
to,
You can’t perform that action at this time.
0 commit comments