Skip to content

Commit 6ce7ea2

Browse files
authored
FIX: prduced exit messages for larger amounts of keys (#2282)
* FIX: prduced exit messages for larger amounts of keys * FIX: copy instead of move files on upload
1 parent dfd7982 commit 6ce7ea2

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

launcher/src/backend/SSHService.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,14 +676,8 @@ export class SSHService {
676676
try {
677677
if (err) throw err;
678678
const readStream = fs.createReadStream(localPath);
679-
// Handle read stream end
680-
readStream.on("end", () => {
681-
fs.unlinkSync(localPath);
682-
});
683-
684679
// Handle read stream errors
685680
readStream.on("error", (error) => {
686-
fs.unlinkSync(localPath);
687681
stream.end();
688682
reject(new Error("Failed to read local file: " + error.message));
689683
});

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,26 @@ const exportExitMessage = async () => {
604604
.filter((item) => item.validatorID === stakingStore.selectedServiceToFilter?.config?.serviceID)
605605
.map((item) => item.key);
606606
607+
// if there are more than 50 keys, split them into chunks of 50
608+
const chunkSize = 50;
609+
if (pubkeys.length > chunkSize) {
610+
let allResults = [];
611+
for (let i = 0; i < pubkeys.length; i += chunkSize) {
612+
const chunk = pubkeys.slice(i, i + chunkSize);
613+
const results = await Promise.all(
614+
chunk.map(async (key) => {
615+
return ControlService.getExitValidatorMessage({
616+
pubkey: key,
617+
serviceID: stakingStore.selectedServiceToFilter.config?.serviceID,
618+
});
619+
})
620+
);
621+
allResults = allResults.concat(results);
622+
}
623+
saveExitMessage(allResults, "multiple");
624+
return;
625+
}
626+
607627
const results = await Promise.all(
608628
pubkeys.map(async (key) => {
609629
return ControlService.getExitValidatorMessage({
@@ -625,7 +645,9 @@ const saveExitMessage = (data, type) => {
625645
const unwrap = (entry) => (entry && entry.data ? entry.data : entry);
626646
627647
const content =
628-
type === "single" ? JSON.stringify(unwrap(data), null, 2) : data.map((entry) => JSON.stringify(unwrap(entry), null, 2)).join("\n\n");
648+
type === "single"
649+
? JSON.stringify(unwrap(data), null, 2)
650+
: "[" + data.map((entry) => JSON.stringify(unwrap(entry), null, 2)).join(",\n") + "]";
629651
630652
const fileName = type === "single" ? "single_exit_message.txt" : "multiple_exit_messages.txt";
631653
const blob = new Blob([content], { type: "application/json;charset=utf-8" });

0 commit comments

Comments
 (0)