Fix crypto lib call crash with custom function

This commit is contained in:
softsimon
2024-07-21 22:54:58 +08:00
parent 8116b50d50
commit 743c7e8bfb
2 changed files with 16 additions and 3 deletions

View File

@@ -181,4 +181,17 @@ export function uncompressDeltaChange(delta: MempoolBlockDeltaCompressed): Mempo
acc: !!tx[3],
}))
};
}
}
export function simpleRandomUUID(): string {
const hexDigits = '0123456789abcdef';
const uuidLengths = [8, 4, 4, 4, 12];
let uuid = '';
for (const length of uuidLengths) {
for (let i = 0; i < length; i++) {
uuid += hexDigits[Math.floor(Math.random() * 16)];
}
uuid += '-';
}
return uuid.slice(0, -1);
}