Closed logiclrd closed 11 years ago
Oh, and the structure explicitly lists intervals to guarantee a specific ordering of them in the grid. Technically, PHP's maps are already ordered, but a caller decoding the JSON in some other language might end up putting the data into a structure that does not guarantee order.
Merged. Thanks for the contribution!
Added support for a separate endpoint returning hashrate stats in JSON format:
The refactored code used to assign to local variables $u16avghash, $u16shares, $u2avghash, $u2shares and then an array $my_shares with entries for 256- and 128-second intervals. Its updated form consolidates all of these down to a single object, and that object is structured as a set of maps. Each map has the same set of properties, so that they can be processed identically by a caller. A typical object looks like this (once encoded in JSON):
This object provides everything that userstats.php needs to generate its table, and is also exactly the data that I want to be able to export as JSON.