Skip to content

Commit 3166a2f

Browse files
committed
Fixed exiting large amount of validators problem
1 parent f6ec3e2 commit 3166a2f

File tree

2 files changed

+43
-21
lines changed

2 files changed

+43
-21
lines changed

launcher/src/backend/SSHService.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,22 @@ export class SSHService {
110110
getConnectionFromPool() {
111111
let conn;
112112
let maxVal = 5;
113-
while (!conn && maxVal < 10) {
113+
while (!conn && maxVal < 50) {
114114
conn = this.connectionPool.find((c) => c._chanMgr._count < maxVal);
115115
maxVal++;
116116
}
117117
return conn;
118118
}
119119

120+
async getConnectionFromPoolWithCheck() {
121+
let conn = this.getConnectionFromPool()
122+
if (conn) {
123+
return conn
124+
}
125+
await this.checkConnectionPool()
126+
return this.getConnectionFromPool()
127+
}
128+
120129
async connect(connectionInfo, currentWindow = null) {
121130
this.connectionInfo = connectionInfo;
122131
let conn = new Client();
@@ -220,8 +229,8 @@ export class SSHService {
220229
}
221230

222231
async execCommand(command) {
223-
return new Promise((resolve, reject) => {
224-
let conn = this.getConnectionFromPool();
232+
return new Promise(async (resolve, reject) => {
233+
let conn = await this.getConnectionFromPoolWithCheck();
225234

226235
const data = {
227236
rc: -1,

launcher/src/components/UI/staking-page/StakingScreen.vue

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -593,20 +593,26 @@ const withdrawValidatorKey = async () => {
593593
} else {
594594
// If multiple keys
595595
const multiKeys = stakingStore.keys
596-
597596
.filter((item) => item.validatorID === stakingStore.selectedServiceToFilter.config?.serviceID)
598597
.map((item) => item.key);
599598
600-
res = await Promise.all(
601-
multiKeys.map(async (key) => {
602-
return await ControlService.exitValidatorAccount({
603-
pubkey: key,
604-
serviceID: stakingStore.selectedServiceToFilter.config?.serviceID,
605-
});
606-
})
607-
);
599+
let results = []
600+
for (let i = 0; i < multiKeys.length; i += 50) {
601+
const end = i+50
602+
results = [
603+
...results,
604+
...(await Promise.all(
605+
multiKeys.slice(i, end > multiKeys.length ? multiKeys.length : end).map(async (key) => {
606+
return ControlService.exitValidatorAccount({
607+
pubkey: key,
608+
serviceID: stakingStore.selectedServiceToFilter.config?.serviceID,
609+
});
610+
})
611+
)),
612+
]
613+
}
608614
609-
stakingStore.withdrawAndExitResponse = res.map((item, index) => {
615+
stakingStore.withdrawAndExitResponse = results.map((item, index) => {
610616
let responseObj = {
611617
pubkey: multiKeys[index],
612618
code: null,
@@ -684,14 +690,21 @@ const exportExitMessage = async () => {
684690
.filter((item) => item.validatorID === stakingStore.selectedServiceToFilter?.config?.serviceID)
685691
.map((item) => item.key);
686692
687-
const results = await Promise.all(
688-
pubkeys.map(async (key) => {
689-
return ControlService.getExitValidatorMessage({
690-
pubkey: key,
691-
serviceID: stakingStore.selectedServiceToFilter.config?.serviceID,
692-
});
693-
})
694-
);
693+
let results = []
694+
for (let i = 0; i < pubkeys.length; i += 50) {
695+
const end = i+50
696+
results = [
697+
...results,
698+
...(await Promise.all(
699+
pubkeys.slice(i, end > pubkeys.length ? pubkeys.length : end).map(async (key) => {
700+
return ControlService.getExitValidatorMessage({
701+
pubkey: key,
702+
serviceID: stakingStore.selectedServiceToFilter.config?.serviceID,
703+
});
704+
})
705+
)),
706+
]
707+
}
695708
696709
saveExitMessage(results, "multiple");
697710
}

0 commit comments

Comments
 (0)