MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / Difficulty

Method Difficulty

crypto/hash/hash.go:118–132  ·  view source on GitHub ↗

Difficulty returns the leading Zero **bit** count of Hash in binary. return -1 indicate the Hash pointer is nil.

()

Source from the content-addressed store, hash-verified

116// Difficulty returns the leading Zero **bit** count of Hash in binary.
117// return -1 indicate the Hash pointer is nil.
118func (h *Hash) Difficulty() (difficulty int) {
119 if h == nil {
120 return -1
121 }
122
123 for i := range *h {
124 v := (*h)[HashSize-i-1]
125 if v != byte(0) {
126 difficulty = 8 * i
127 difficulty += bits.LeadingZeros8(v)
128 return
129 }
130 }
131 return HashSize * 8
132}
133
134// MarshalJSON implements the json.Marshaler interface.
135func (h Hash) MarshalJSON() ([]byte, error) {

Callers 3

TestHash_DifficultyFunction · 0.45
nonceGenFunction · 0.45
PingMethod · 0.45

Calls

no outgoing calls

Tested by 1

TestHash_DifficultyFunction · 0.36