powrespecter on Nostr: If it helps here's the little js function I use to count the bits of work for the ...
If it helps here's the little js function I use to count the bits of work for the webui at https://powrelay.xyz
function zeroLeadingBitsCount(hex32) {
let count = 0;
for (let i = 0; i < 64; i += 2) {
const hexbyte = hex32.slice(i, i + 2); // grab next byte
if (hexbyte == '00') {
count += 8;
continue;
}
// reached non-zero byte; count number of 0 bits in hexbyte
const bits = parseInt(hexbyte, 16).toString(2).padStart(8, '0');
for (let b = 0; b < 8; b++) {
if (bits[b] == '1' ) {
break; // reached non-zero bit; stop
}
count += 1;
}
break;
}
return count;
};
You could add this to your site and have some code that only shows posts with more than some number. Then you'll need to add a function to let users generate pow locally on their browsers.
function zeroLeadingBitsCount(hex32) {
let count = 0;
for (let i = 0; i < 64; i += 2) {
const hexbyte = hex32.slice(i, i + 2); // grab next byte
if (hexbyte == '00') {
count += 8;
continue;
}
// reached non-zero byte; count number of 0 bits in hexbyte
const bits = parseInt(hexbyte, 16).toString(2).padStart(8, '0');
for (let b = 0; b < 8; b++) {
if (bits[b] == '1' ) {
break; // reached non-zero bit; stop
}
count += 1;
}
break;
}
return count;
};
You could add this to your site and have some code that only shows posts with more than some number. Then you'll need to add a function to let users generate pow locally on their browsers.