Skip to content

Commit e48c049

Browse files
committed
Merge branch 'test'
2 parents 87620cc + dd070e7 commit e48c049

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

src/pages/Home/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const Home = () => {
155155
};
156156

157157
_getAllRegions()
158-
}, [allRegions]);
158+
}, []);
159159

160160
const handleTogglePower = async () => {
161161
setIsConnectionLoading(true)

src/services/listeners.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
import { blast_CNTPAbi, ClaimableConetPointAbi } from "./../utils/abis";
1+
import { blast_CNTPAbi } from "./../utils/abis";
22
import { ethers } from "ethers";
33
import {
44
conetDepinProvider,
55
conetProvider,
66
ethProvider,
77
} from "../utils/constants";
8-
import { CoNET_Data, setCoNET_Data } from "../utils/globals";
8+
import {
9+
CoNET_Data,
10+
processingBlock,
11+
setCoNET_Data,
12+
setProcessingBlock,
13+
} from "../utils/globals";
914
import contracts from "../utils/contracts";
1015
import { initProfileTokens } from "../utils/utils";
11-
import { getFreePassportInfo, getVpnTimeUsed } from "./wallets";
16+
import { getVpnTimeUsed } from "./wallets";
1217

1318
let epoch = 0;
1419

@@ -19,19 +24,27 @@ const listenProfileVer = async (callback: (profiles: profile[]) => void) => {
1924
if (block === epoch + 1) {
2025
epoch++;
2126

22-
const profiles = CoNET_Data?.profiles;
23-
if (!profiles) {
24-
return;
25-
}
26-
const runningList: any[] = [];
27+
if (processingBlock === true) return;
28+
29+
if (block % 10 === 0) {
30+
setProcessingBlock(true);
2731

28-
runningList.push(getProfileAssets(profiles[0]));
32+
const profiles = CoNET_Data?.profiles;
33+
if (!profiles) {
34+
return;
35+
}
36+
const runningList: any[] = [];
2937

30-
await Promise.all(runningList);
38+
runningList.push(getProfileAssets(profiles[0]));
3139

32-
await getVpnTimeUsed();
40+
await Promise.all(runningList);
3341

34-
if (CoNET_Data?.profiles[0]) callback(CoNET_Data?.profiles);
42+
await getVpnTimeUsed();
43+
44+
if (CoNET_Data?.profiles[0]) callback(CoNET_Data?.profiles);
45+
46+
setProcessingBlock(false);
47+
}
3548
}
3649
});
3750

src/utils/globals.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
let CoNET_Data: encrypt_keys_object | null = null;
2+
let processingBlock: boolean = false;
23

34
const setCoNET_Data = (data: encrypt_keys_object | null) => {
45
CoNET_Data = data;
56
};
67

7-
export { CoNET_Data, setCoNET_Data };
8+
const setProcessingBlock = (value: boolean) => {
9+
processingBlock = value;
10+
};
11+
12+
export { CoNET_Data, setCoNET_Data, processingBlock, setProcessingBlock };

0 commit comments

Comments
 (0)