Minor improvements in the worker

This commit is contained in:
NicolasCantu 2025-02-13 10:22:05 +01:00
parent 57684eba6b
commit 682ab03861

View File

@ -32,13 +32,10 @@ self.addEventListener('message', async (event) => {
// Iterate on each process
if (myProcesses && myProcesses.length != 0) {
console.log(myProcesses);
for (const process of myProcesses) {
console.log(process);
// Iterate on states
for (const state of process.states) {
if (!state.pcd_commitment) continue;
console.log(state);
// iterate on pcd_commitment
for (const hash of Object.values(state.pcd_commitment)) {
// Check if we have the data in db
@ -49,8 +46,9 @@ self.addEventListener('message', async (event) => {
await addDiff(process, state, hash)
} else {
// We remove it if we have it in the set
console.log(`Removing ${hash} from the set`);
toDownload.delete(hash);
if (toDownload.delete(hash)) {
console.log(`Removing ${hash} from the set`);
}
}
}
}
@ -260,7 +258,6 @@ async function addDiff(processId, stateId, hash) {
});
if (!existingDiff) {
console.log('Inserting a diff');
const newDiff = {
process_id: processId,
state_id: stateId,