Weather station oracle#34
Conversation
Amxx
left a comment
There was a problem hiding this comment.
Minors improvements would be nice (see comments). Otherwise good work
| struct Location | ||
| { | ||
| string location; | ||
| mapping(uint256 => WeatherReport) reports; |
There was a problem hiding this comment.
it would be nice to have reports as an array of WeatherReport (each WeatherReport containing the associated time).
That way we can traverse the history / get the latest value easily.
Another solution is to only store the latest report and rely on offchain services (such as TheGraph) to index past events
There was a problem hiding this comment.
I thought it could be nice to use an array as well. But as we allow users to pass a specific timestamp, the reports being fetched will not necessarily be in a correct time order, that's why I used a mapping instead. Don't you think it is better in this case ?
Doracle address : 0xdffFa5f74Ba05A21C8A10E76d41f50F8A0858A5F
Docker container : https://hub.docker.com/r/andy92pac/weather-station
Smart contract address : 0x3980652C5b1dc731A97af99c91b23A017a170f4c
The Doracle is using DarkSky api to get description of the weather at a specific location.
Using this api, it is possible to get access to historical data as well as upcoming forecast. Past and future timestamps are therefore valid.
The description of the weather can get the following values : clear-day, clear-night, rain, snow, sleet, wind, fog, cloudy, partly-cloudy-day and partly-cloudy-night