Skip to content

Commit

Permalink
Merge pull request #25 from erigontech/peername
Browse files Browse the repository at this point in the history
added dl handel
  • Loading branch information
dvovk authored Oct 13, 2024
2 parents 8252260 + d7164f7 commit dd2a317
Show file tree
Hide file tree
Showing 3 changed files with 1,114 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Network/APIGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import {
fetchSnapshotSync,
fetchSyncStages,
fetchVersion,
logListUrl
logListUrl,
fetchTorrentStats
} from "./APIHandler";
import { nodeInfoFromJson, nodeInfoFromJsonLocal } from "../helpers/nodeInfoFromJson";
import { flagsFromJson } from "../helpers/flagsFromJson";
Expand Down Expand Up @@ -446,3 +447,13 @@ export const getMemoryInfo = () => {
console.log("Error fetching memory info: ", error);
});
};

export const getTorrentStats = () => {
fetchTorrentStats()
.then((response) => {
//store.dispatch(addOrUpdateTorrentStats({ nodeId: getNodeId(), stats: response }));
})
.catch((error) => {
console.log("Error fetching torrent stats: ", error);
});
};
19 changes: 18 additions & 1 deletion src/Network/APIHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
getHeadersMock,
getNetworkSpeedMock,
nodeInfoMock,
syncStatsMock
syncStatsMock,
snpDLmock
} from "./../../tests/mocks";

import { cpuUsageMock, hardwareInfoMock, memoryInfoMock, processesInfoMock } from "../../tests/sysinfo_mock";
Expand Down Expand Up @@ -50,6 +51,7 @@ const heapProfileVarName = "pprof/heap";
const allocsProfileVarName = "pprof/allocs";
const blockProfileVarName = "pprof/block";
const mutexProfileVarName = "pprof/mutex";
const torrentStatsVarName = "torrent-stats";

export const getActiveSessionPin = (): string => {
return store.getState().app.activeSessionPin;
Expand Down Expand Up @@ -190,6 +192,10 @@ export const mutexProfileUrl = () => {
return `${currentNodeUrl(true)}/${mutexProfileVarName}`;
};

export const torrentStatsUrl = () => {
return `${currentNodeUrl(true)}/${torrentStatsVarName}`;
};

export const fetchBackendUrl = () => {
if (import.meta.env.VITE_SERVER_RESPONSE_TYPE === "MOCK") {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -461,6 +467,17 @@ export const fetchMemoryInfo = () => {
}
};

export const fetchTorrentStats = () => {
if (import.meta.env.VITE_SERVER_RESPONSE_TYPE === "MOCK") {
return new Promise((resolve, reject) => {
resolve(snpDLmock);
});
} else {
const request = createRequest(torrentStatsUrl(), "GET");
return fetchRequest(request);
}
};

const fetchRequest = (request: Request) => {
return fetch(request)
.then((response) => {
Expand Down
Loading

0 comments on commit dd2a317

Please sign in to comment.