MCPcopy Create free account
hub / github.com/cameri/nostream / getLeadingZeroBits

Function getLeadingZeroBits

src/utils/proof-of-work.ts:1–12  ·  view source on GitHub ↗
(hash: Buffer)

Source from the content-addressed store, hash-verified

1export function getLeadingZeroBits(hash: Buffer) {
2 let total: number, i: number, bits: number
3
4 for (i = 0, total = 0; i < hash.length; i++) {
5 bits = msb(hash[i])
6 total += bits
7 if (bits != 8) {
8 break
9 }
10 }
11 return total
12}
13
14function msb(b: number) {
15 let n = 0

Callers 3

getEventProofOfWorkFunction · 0.90
getPubkeyProofOfWorkFunction · 0.90

Calls 1

msbFunction · 0.85

Tested by

no test coverage detected