mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-15 12:58:45 +00:00
chore: set up commitlint, husky, and prettier (#1451)
* chore: add prettier configuration Signed-off-by: Xe Iaso <me@xeiaso.net> * format: run prettier tree-wide Signed-off-by: Xe Iaso <me@xeiaso.net> * chore(prettier): ignore intentionally ungrammatical files Signed-off-by: Xe Iaso <me@xeiaso.net> * ci: add PR title lint rule Signed-off-by: Xe Iaso <me@xeiaso.net> * ci: add DCO check Signed-off-by: Xe Iaso <me@xeiaso.net> * chore: add commitlint and husky Signed-off-by: Xe Iaso <me@xeiaso.net> * chore: add CONTRIBUTING guidelines Signed-off-by: Xe Iaso <me@xeiaso.net> * chore: set SKIP_INTEGRATION in precommit tests Signed-off-by: Xe Iaso <me@xeiaso.net> * chore: update spelling Signed-off-by: Xe Iaso <me@xeiaso.net> * ci(dco): remove reopened trigger Signed-off-by: Xe Iaso <me@xeiaso.net> * chore: remove dead file Signed-off-by: Xe Iaso <me@xeiaso.net> * chore(prettier): don't format nginx includes Signed-off-by: Xe Iaso <me@xeiaso.net> --------- Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -6,7 +6,10 @@ const calculateSHA256 = async (input: string) => {
|
||||
};
|
||||
|
||||
const toHexString = (byteArray: Uint8Array) => {
|
||||
return byteArray.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
|
||||
return byteArray.reduce(
|
||||
(str, byte) => str + byte.toString(16).padStart(2, "0"),
|
||||
"",
|
||||
);
|
||||
};
|
||||
|
||||
addEventListener("message", async ({ data: eventData }) => {
|
||||
@@ -18,7 +21,7 @@ addEventListener("message", async ({ data: eventData }) => {
|
||||
const requiredZeroBytes = Math.floor(difficulty / 2);
|
||||
const isDifficultyOdd = difficulty % 2 !== 0;
|
||||
|
||||
for (; ;) {
|
||||
for (;;) {
|
||||
const hashBuffer = await calculateSHA256(data + nonce);
|
||||
const hashArray = new Uint8Array(hashBuffer);
|
||||
|
||||
@@ -31,7 +34,7 @@ addEventListener("message", async ({ data: eventData }) => {
|
||||
}
|
||||
|
||||
if (isValid && isDifficultyOdd) {
|
||||
if ((hashArray[requiredZeroBytes] >> 4) !== 0) {
|
||||
if (hashArray[requiredZeroBytes] >> 4 !== 0) {
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +55,7 @@ addEventListener("message", async ({ data: eventData }) => {
|
||||
|
||||
/* Truncate the decimal portion of the nonce. This is a bit of an evil bit
|
||||
* hack, but it works reliably enough. The core of why this works is:
|
||||
*
|
||||
*
|
||||
* > 13.4 % 1 !== 0
|
||||
* true
|
||||
* > 13 % 1 !== 0
|
||||
@@ -67,4 +70,4 @@ addEventListener("message", async ({ data: eventData }) => {
|
||||
postMessage(nonce);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user