// AddHash will add the given uint64 hash to the HLL
439246
func (h *HLL) AddHash(hash uint64) {
	switch h.format {
	case NORMAL:
		h.addNormal(hash)
	case SPARSE:
		h.addSparse(hash)
	}
}
796541
func (h HLL) Add(hash uint64) {
	if h[0]&(1<<6) != 0 {
		if Dense(h[8:]).Add(hash) {
			h[0] |= 1 << 7 // Mark as dirty.
		}
		return
	}
	s := sparse(h)
	if s.Add(hash) == ok {
		return
	}
	toDense(s)
	Dense(h[8:]).Add(hash)
}
47360
func RegisterHash(h Hash, f func() hash.Hash) {
	if h >= maxHash {
		panic("crypto: RegisterHash of unknown hash function")
	}
	hashes[h] = f
}
434080
func Hash(s string) string {
	return fmt.Sprintf("%x", md5.Sum([]byte(s)))
}
232893
func (f *file) Hash() []byte {
	if f.hash == nil {
		h := fnv.New64a()
		h.Write([]byte(f.contents)) // it nevers returns an error.
		f.hash = h.Sum(nil)
	}

	return f.hash
}
1054059
func NewHashFromHex(hex string) (hash *Hash, _ error) {
	h := new(Hash)
	if err := h.SetHex(hex); err != nil {
		return nil, err
	}
	return h, nil
}
871775
func (d *dir) calculateHash() {
	h := fnv.New64a()
	h.Write([]byte("dir "))
	for _, c := range d.children {
		h.Write([]byte(c.Name()))
		h.Write([]byte(" "))
		h.Write(c.Hash())
	}
	d.hash = h.Sum([]byte{})
}
1187845
func SealHash(header *types.Header) (hash common.Hash) {
	hasher := sha3.NewLegacyKeccak256()
	encodeSigHeader(hasher, header)
	hasher.Sum(hash[:0])
	return hash
}
151395
func (h *HLL) AddWithHasher(value string, hasher func(string) uint64) {
	hash := hasher(value)
	h.AddHash(hash)
}
959788
func idHash(rType, protocol string, toPort, fromPort int64, self bool) string {
	var buf bytes.Buffer
	buf.WriteString(fmt.Sprintf("%s-", rType))
	buf.WriteString(fmt.Sprintf("%d-", toPort))
	buf.WriteString(fmt.Sprintf("%d-", fromPort))
	buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(protocol)))
	buf.WriteString(fmt.Sprintf("%t-", self))

	return fmt.Sprintf("rule-%d", hashcode.String(buf.String()))
}
908605
func (h *BytesRefHash) Add(bytes []byte) (int, error) {
	assert2(h.bytesStart != nil, "Bytesstart is null - not initialized")
	length := len(bytes)
	// final position
	hashPos := h.findHash(bytes)
	e := h.ids[hashPos]

	if e == -1 {
		// new entry
		if len2 := 2 + len(bytes); len2+h.pool.ByteUpto > BYTE_BLOCK_SIZE {
			if len2 > BYTE_BLOCK_SIZE {
				return 0, MaxBytesLengthExceededError(fmt.Sprintf(
					"bytes can be at most %v in length; got %v",
					BYTE_BLOCK_SIZE-2, len(bytes)))
			}
			h.pool.NextBuffer()
		}
		buffer := h.pool.Buffer
		bufferUpto := h.pool.ByteUpto
		if h.count >= len(h.bytesStart) {
			h.bytesStart = h.bytesStartArray.Grow()
			assert2(h.count < len(h.bytesStart)+1, "count: %v len: %v", h.count, len(h.bytesStart))
		}
		e = h.count
		h.count++

		h.bytesStart[e] = bufferUpto + h.pool.ByteOffset

		// We first encode the length, followed by the bytes. Length is
		// encoded as vint, but will consume 1 or 2 bytes at most (we
		// reject too-long terms, above).
		if length < 128 {
			// 1 byte to store length
			buffer[bufferUpto] = byte(length)
			h.pool.ByteUpto += length + 1
			assert2(length >= 0, "Length must be positive: %v", length)
			copy(buffer[bufferUpto+1:], bytes)
		} else {
			// 2 bytes to store length
			buffer[bufferUpto] = byte(0x80 | (length & 0x7f))
			buffer[bufferUpto+1] = byte((length >> 7) & 0xff)
			h.pool.ByteUpto += length + 2
			copy(buffer[bufferUpto+2:], bytes)
		}
		assert(h.ids[hashPos] == -1)
		h.ids[hashPos] = e

		if h.count == h.hashHalfSize {
			h.rehash(2*h.hashSize, true)
		}
		return e, nil
	}
	return -(e + 1), nil
}
486495
func (apic *APICache) blockHash(height int64) (chainhash.Hash, bool) {
	apic.mtx.RLock()
	defer apic.mtx.RUnlock()
	hash, ok := apic.MainchainBlocks[height]
	return hash, ok
}
518197
func Hash(what []byte) uint32 {
	h := fnv.New32()
	h.Write(what)
	return h.Sum32()
}
103988
func (msg *MsgMerkleBlock) AddTxHash(hash *chainhash.Hash) error {
	if len(msg.Hashes)+1 > maxTxPerBlock {
		str := fmt.Sprintf("too many tx hashes for message [max %v]",
			maxTxPerBlock)
		return messageError("MsgMerkleBlock.AddTxHash", str)
	}

	msg.Hashes = append(msg.Hashes, hash)
	return nil
}
81327
func MMH3Hash(value string) uint64 {
	h1, _ := mmh3.Hash128(value)
	return h1
}
860910
func (a *managedAddress) AddrHash() []byte {
	var hash []byte

	switch n := a.address.(type) {
	case *btcutil.AddressPubKeyHash:
		hash = n.Hash160()[:]
	case *btcutil.AddressScriptHash:
		hash = n.Hash160()[:]
	case *btcutil.AddressWitnessPubKeyHash:
		hash = n.Hash160()[:]
	}

	return hash
}
24960
func (idx *MemoryIndex) FindHash(o int64) (plumbing.Hash, error) {
	var hash plumbing.Hash
	var ok bool

	if idx.offsetHash != nil {
		if hash, ok = idx.offsetHash[o]; ok {
			return hash, nil
		}
	}

	// Lazily generate the reverse offset/hash map if required.
	if !idx.offsetHashIsFull || idx.offsetHash == nil {
		if err := idx.genOffsetHash(); err != nil {
			return plumbing.ZeroHash, err
		}

		hash, ok = idx.offsetHash[o]
	}

	if !ok {
		return plumbing.ZeroHash, plumbing.ErrObjectNotFound
	}

	return hash, nil
}