-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made miner look nice and work with the new server patch
- Loading branch information
Showing
4 changed files
with
134 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const difficulty = 0; | ||
|
||
function getRandomInt(min, max) { | ||
min = Math.ceil(min); | ||
max = Math.floor(max); | ||
return Math.floor(Math.random() * (max - min)) + min; | ||
} | ||
|
||
function checkHash(difficulty, hash){ | ||
|
||
const hex = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'] | ||
|
||
let preKey = '' | ||
|
||
for(let i = 0; i <= Math.floor((difficulty - 1)/16); i++){ | ||
|
||
preKey += '0' | ||
} | ||
|
||
if (difficulty % 16 != 0){ | ||
|
||
for (let i = 0; i < (16 - (difficulty % 16)); i++){ | ||
|
||
if (hash.startsWith(preKey + hex[i])){ | ||
|
||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
|
||
}else{ | ||
|
||
return hash.startsWith(preKey) | ||
} | ||
|
||
} | ||
|
||
console.log(new Date().getTime()) | ||
|
||
console.log(checkHash(32, '00a')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters