@@ -40,10 +40,8 @@ pub struct CallContext {
40
40
/// Cycles that were sent in the request that created the `CallContext`.
41
41
available_cycles : Cycles ,
42
42
43
- /// Point in time at which the `CallContext` was created. This field is only
44
- /// optional to accommodate contexts that were created before this field was
45
- /// added.
46
- time : Option < Time > ,
43
+ /// Point in time at which the `CallContext` was created.
44
+ time : Time ,
47
45
48
46
/// The total number of instructions executed in the given call context.
49
47
/// This value is used for the `ic0.performance_counter` type 1.
@@ -63,7 +61,7 @@ impl CallContext {
63
61
responded,
64
62
deleted,
65
63
available_cycles,
66
- time : Some ( time ) ,
64
+ time,
67
65
instructions_executed : NumInstructions :: default ( ) ,
68
66
}
69
67
}
@@ -113,7 +111,7 @@ impl CallContext {
113
111
}
114
112
115
113
/// The point in time at which the call context was created.
116
- pub fn time ( & self ) -> Option < Time > {
114
+ pub fn time ( & self ) -> Time {
117
115
self . time
118
116
}
119
117
@@ -132,7 +130,7 @@ impl From<&CallContext> for pb::CallContext {
132
130
responded : item. responded ,
133
131
deleted : item. deleted ,
134
132
available_funds : Some ( ( & funds) . into ( ) ) ,
135
- time_nanos : item. time . map ( |t| t . as_nanos_since_unix_epoch ( ) ) ,
133
+ time_nanos : item. time . as_nanos_since_unix_epoch ( ) ,
136
134
instructions_executed : item. instructions_executed . get ( ) ,
137
135
}
138
136
}
@@ -149,7 +147,7 @@ impl TryFrom<pb::CallContext> for CallContext {
149
147
responded : value. responded ,
150
148
deleted : value. deleted ,
151
149
available_cycles : funds. cycles ( ) ,
152
- time : value . time_nanos . map ( Time :: from_nanos_since_unix_epoch) ,
150
+ time : Time :: from_nanos_since_unix_epoch ( value . time_nanos ) ,
153
151
instructions_executed : value. instructions_executed . into ( ) ,
154
152
} )
155
153
}
@@ -335,7 +333,7 @@ impl CallContextManager {
335
333
responded : false ,
336
334
deleted : false ,
337
335
available_cycles : cycles,
338
- time : Some ( time ) ,
336
+ time,
339
337
instructions_executed : NumInstructions :: default ( ) ,
340
338
} ,
341
339
) ;
@@ -581,15 +579,10 @@ impl CallContextManager {
581
579
// context that isn't old enough.
582
580
self . call_contexts
583
581
. iter ( )
584
- . take_while ( |( _, call_context) | match call_context. time ( ) {
585
- Some ( context_time) => context_time + age <= current_time,
586
- None => true ,
587
- } )
582
+ . take_while ( |( _, call_context) | call_context. time ( ) + age <= current_time)
588
583
. filter_map ( |( _, call_context) | {
589
- if let Some ( time) = call_context. time ( ) {
590
- if !call_context. is_deleted ( ) {
591
- return Some ( ( call_context. call_origin ( ) , time) ) ;
592
- }
584
+ if !call_context. is_deleted ( ) {
585
+ return Some ( ( call_context. call_origin ( ) , call_context. time ( ) ) ) ;
593
586
}
594
587
None
595
588
} )
0 commit comments