@@ -36,7 +36,7 @@ import {
36
36
* "wat": "ETH/USD",
37
37
* "bar": 13,
38
38
* "decimals": 18,
39
- * "maxAllowedAge ": <time in seconds>,
39
+ * "stalenessThreshold ": <time in seconds>,
40
40
* "feeds": [
41
41
* "<Ethereum address>",
42
42
* ...
@@ -117,7 +117,7 @@ contract IScribeChaincheck is Chaincheck {
117
117
check_decimals ();
118
118
119
119
// Liveness:
120
- check_beingPoked ();
120
+ check_stalenessThreshold ();
121
121
122
122
// Configurations:
123
123
check_bar ();
@@ -226,8 +226,8 @@ contract IScribeChaincheck is Chaincheck {
226
226
227
227
// -- Liveness --
228
228
229
- function check_beingPoked () internal {
230
- uint maxAllowedAge = config.readUint (".IScribe.maxAllowedAge " );
229
+ function check_stalenessThreshold () internal {
230
+ uint stalenessThreshold = config.readUint (".IScribe.stalenessThreshold " );
231
231
232
232
// Note to make sure address(this) is tolled.
233
233
// Do not forget to diss after afterwards again!
@@ -241,18 +241,20 @@ contract IScribeChaincheck is Chaincheck {
241
241
uint age;
242
242
(ok, val, age) = self.tryReadWithAge ();
243
243
244
+ // Check whether value is provided at all.
244
245
if (! ok) {
245
246
logs.push (StdStyle.red ("Read failed " ));
246
247
}
247
248
248
- if (age > maxAllowedAge) {
249
+ // Check whether value's age is older than allowed.
250
+ if (block .timestamp - age > stalenessThreshold) {
249
251
logs.push (
250
252
string .concat (
251
- StdStyle.red ("Has stale value: " ),
252
- " maxAllowedAge = " ,
253
- vm.toString (maxAllowedAge ),
254
- ", current age= " ,
255
- vm.toString (age)
253
+ StdStyle.red ("Stale value: " ),
254
+ " stalenessThreshold = " ,
255
+ vm.toString (stalenessThreshold ),
256
+ ", age= " ,
257
+ vm.toString (block . timestamp - age)
256
258
)
257
259
);
258
260
}
0 commit comments