|
@@ -30,6 +30,7 @@ import Alert from "@material-ui/lab/Alert";
|
|
|
import Tabs from "@material-ui/core/Tabs";
|
|
|
import Backdrop from "@material-ui/core/Backdrop";
|
|
|
import "./index.css";
|
|
|
+import pako from "pako";
|
|
|
import { alternativeBackendApis } from "../../config";
|
|
|
|
|
|
config();
|
|
@@ -57,8 +58,8 @@ const useStyles = makeStyles((theme: Theme) =>
|
|
|
})
|
|
|
);
|
|
|
|
|
|
-const oldChainStatsLocation =
|
|
|
- "https://joystreamstats.live/static/validators-old-testnet.json";
|
|
|
+const oldChainStatsFileName = "validators-old-testnet.json.gz";
|
|
|
+const oldChainStatsLocation = `https://joystreamstats.live/static/${oldChainStatsFileName}`;
|
|
|
const ValidatorReport = () => {
|
|
|
const dateFormat = "yyyy-MM-DD";
|
|
|
const [oldChainLastDate, setOldChainLastDate] = useState(moment());
|
|
@@ -200,6 +201,7 @@ const ValidatorReport = () => {
|
|
|
};
|
|
|
});
|
|
|
setOldChainRows(filteredStats);
|
|
|
+ setError(undefined);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -209,16 +211,14 @@ const ValidatorReport = () => {
|
|
|
useEffect(() => {
|
|
|
setIsLoading(true);
|
|
|
axios
|
|
|
- .get(oldChainStatsLocation)
|
|
|
+ .get(oldChainStatsLocation, {
|
|
|
+ responseType: "arraybuffer",
|
|
|
+ })
|
|
|
.then((response) => {
|
|
|
try {
|
|
|
- const oldStats = response.data;
|
|
|
- setOldChainStats(oldStats as ValidatorsJSResponse);
|
|
|
- setOldChainLastDate(
|
|
|
- moment(
|
|
|
- oldStats.eraStats[oldStats.eraStats.length - 1].timestampEnded
|
|
|
- )
|
|
|
- );
|
|
|
+ const binData = new Uint8Array(response.data);
|
|
|
+ const decompressedData = pako.inflate(binData);
|
|
|
+ updateOldChainStats(new TextDecoder().decode(decompressedData));
|
|
|
setIsLoading(false);
|
|
|
} catch (err) {
|
|
|
setIsLoading(false);
|
|
@@ -231,6 +231,14 @@ const ValidatorReport = () => {
|
|
|
});
|
|
|
}, []);
|
|
|
|
|
|
+ const updateOldChainStats = (stringData: string) => {
|
|
|
+ const oldStats = JSON.parse(stringData);
|
|
|
+ setOldChainStats(oldStats as ValidatorsJSResponse);
|
|
|
+ setOldChainLastDate(
|
|
|
+ moment(oldStats.eraStats[oldStats.eraStats.length - 1].timestampEnded)
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
updateChainState();
|
|
|
const interval = setInterval(() => {
|