Last active
October 3, 2020 12:40
-
-
Save Filarius/10d246e74bdc5a1be9990ffc8462080b to your computer and use it in GitHub Desktop.
yggdrasil miner helpers
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
// 1665-1650 Kh/s | |
"here is no filter here" | |
// 1635 Kh/s | |
if (T == 1) // high mining | |
{ | |
bool good = true; | |
for (int bcheck = 0; bcheck < conf.high / 8; bcheck++) { | |
if (sha512_hash[bcheck] != 0xFF) | |
{ | |
good = false; | |
break; | |
} | |
} | |
if (good) { | |
int newones = getOnes(sha512_hash); | |
if (newones > conf.high) | |
{ | |
conf.high = newones; | |
fortune_key_index = i; | |
} | |
} | |
} | |
// 1620 Kh/s | |
if (T == 1) // high mining | |
{ | |
bool good = true; | |
/* | |
for (int bcheck = 0; bcheck < conf.high / 8; bcheck++) { | |
if (sha512_hash[bcheck] != 0xFF) | |
{ | |
good = false; | |
break; | |
} | |
}*/ | |
if (good) { | |
//int newones = getOnesPartial(sha512_hash,ffbytes); | |
int newones = getOnes(sha512_hash); | |
if (newones > conf.high) | |
{ | |
conf.high = newones; | |
fortune_key_index = i; | |
} | |
} | |
} | |
// 1650 Kh/s | |
if (T == 1) // high mining | |
{ | |
int newones = getOnes2(sha512_hash); | |
if (newones > conf.high) | |
{ | |
conf.high = newones; | |
fortune_key_index = i; | |
} | |
} | |
int getOnes2(const unsigned char HashValue[crypto_hash_sha512_BYTES]) | |
{ | |
const int map[8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; | |
int lOnes = 0; // кол-во лидирующих единиц | |
for (int i = 0; i < 32; ++i) // всего 32 байта, т.к. лидирующих единиц больше быть не может (32*8 = 256 бит, а ff = 255) | |
{ | |
//std::bitset<8> bits(HashValue[i]); | |
//for (int j = 7; j >= 0; --j) | |
for (int j = 0; j < 8; ++j) | |
{ | |
if (HashValue[i] & map[j]) // if zero then true then there is bit = 1 | |
++lOnes; | |
else | |
return lOnes; | |
} | |
} | |
return -421; // это никогда не случится | |
} |
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
//comparing miner speed using different function to generate byte array representation of IPv6 address while mining for "::" | |
// ~1340 Kh/s | |
void getAddressBytes2(unsigned char HashValue[crypto_hash_sha512_BYTES], byte ipAddr[16]){ | |
int lErase = getOnes(HashValue) + 1; // лидирующие единицы и первый ноль | |
bool changeit = false; | |
int bigbyte = 0; | |
for(int j = 0; j < lErase; ++j) // побитовое смещение | |
{ | |
for(int i = 63; i >= 0; --i) | |
{ | |
if(bigbyte == i+1) // предыдущий байт требует переноса | |
changeit = true; | |
if(HashValue[i] & 0x80) | |
bigbyte = i; | |
HashValue[i] <<= 1; | |
if(changeit) | |
{ | |
HashValue[i] |= 0x01; | |
changeit = false; | |
} | |
} | |
} | |
ipAddr[0] = 0x02; | |
ipAddr[1] = lErase - 1; | |
for (int i = 0; i < 14; ++i) | |
ipAddr[i + 2] = HashValue[i]; | |
} | |
// ~1560 Kh/s | |
void getAddressBytes(unsigned char HashValue[crypto_hash_sha512_BYTES], byte arr[16]){ | |
int ones = getOnes(HashValue) ; | |
int start = (ones + 1); // лидирующие единицы и первый ноль | |
int bitshift = start % 8; | |
start = start/8; | |
if (bitshift != 0){ | |
for (int i = start;i<start+15;i++){ | |
HashValue[i] <<= bitshift; | |
HashValue[i] |= HashValue[i+1] >> (8-bitshift); | |
} | |
} | |
arr[0] = 0x02; | |
arr[1] = ones; | |
for (int i = 0; i < 14; ++i) | |
arr[i + 2] = HashValue[i+start]; | |
} | |
// ~1585 Kh/s | |
void getAddressBytes(unsigned char HashValue[crypto_hash_sha512_BYTES], byte arr[16]){ | |
int ones = getOnes(HashValue) ; | |
int start = (ones + 1); // лидирующие единицы и первый ноль | |
int bitshift = start % 8; | |
start = start/8; | |
for (int i = start;i<start+15;i++){ | |
HashValue[i] <<= bitshift; | |
HashValue[i] |= HashValue[i+1] >> (8-bitshift); | |
} | |
arr[0] = 0x02; | |
arr[1] = ones; | |
for (int i = 0; i < 14; ++i) | |
arr[i + 2] = HashValue[i+start]; | |
} | |
// ~1575 Kh/s | |
void getAddressBytes(unsigned char HashValue[crypto_hash_sha512_BYTES], byte arr[16]){ | |
int ones = getOnes(HashValue) ; | |
int start = (ones + 1); // лидирующие единицы и первый ноль | |
int bitshift = start % 8; | |
start = start/8; | |
for (int i = 0;i<15;i++){ | |
HashValue[i+start] <<= bitshift; | |
HashValue[i+start] |= HashValue[i+start+1] >> (8-bitshift); | |
} | |
arr[0] = 0x02; | |
arr[1] = ones; | |
for (int i = 0; i < 14; ++i) | |
arr[i + 2] = HashValue[i+start]; | |
} | |
// ~1530 Kh/s | |
void getAddressBytes2(unsigned char HashValue[crypto_hash_sha512_BYTES], byte ipAddr[16]){ | |
int lErase = getOnes(HashValue) + 1; // лидирующие единицы и первый ноль | |
int start = lErase / 8; | |
int shift = lErase % 8; | |
bool changeit = false; | |
int bigbyte = 0; | |
for(int j = 0; j < shift; ++j) // побитовое смещение | |
{ | |
for(int i = start+15; i >= start; --i) | |
{ | |
if(bigbyte == i+1) // предыдущий байт требует переноса | |
changeit = true; | |
if(HashValue[i] & 0x80) | |
bigbyte = i; | |
HashValue[i] <<= 1; | |
if(changeit) | |
{ | |
HashValue[i] |= 0x01; | |
changeit = false; | |
} | |
} | |
} | |
ipAddr[0] = 0x02; | |
ipAddr[1] = lErase - 1; | |
for (int i = 0; i < 14; ++i) | |
ipAddr[i + 2] = HashValue[i+start]; | |
} |
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
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
такс-такс-такс что тут у нас :^)