// NormalizedBundleHash normalizes the given bundle hash, with resulting digits summing to zero.
// It returns a slice with the tryte decimal representation without any 13/M values.
342635
func NormalizedBundleHash(bundleHash Hash) []int8 {
	normalizedBundle := make([]int8, HashTrytesSize)
	for i := 0; i < MaxSecurityLevel; i++ {
		sum := 0
		for j := 0; j < 27; j++ {
			normalizedBundle[i*27+j] = int8(TritsToInt(MustTrytesToTrits(string(bundleHash[i*27+j]))))
			sum += int(normalizedBundle[i*27+j])
		}

		if sum >= 0 {
			for ; sum > 0; sum-- {
				for j := 0; j < 27; j++ {
					if normalizedBundle[i*27+j] > MinTryteValue {
						normalizedBundle[i*27+j]--
						break
					}
				}
			}
		} else {
			for ; sum < 0; sum++ {
				for j := 0; j < 27; j++ {
					if normalizedBundle[i*27+j] < MaxTryteValue {
						normalizedBundle[i*27+j]++
						break
					}
				}
			}
		}
	}
	return normalizedBundle
}
918003
func (b *Backend) Rehash() uint64 {
	// If we have no backend, the value is zero
	if b == nil {
		return 0
	}

	// Use hashstructure to hash only our type with the config.
	code, err := hashstructure.Hash(map[string]interface{}{
		"type":   b.Type,
		"config": b.RawConfig.Raw,
	}, nil)

	// This should never happen since we have just some basic primitives
	// so panic if there is an error.
	if err != nil {
		panic(err)
	}

	return code
}
586171
func (num Number) Hash() int {
	f, err := json.Number(num).Float64()
	if err != nil {
		bs := []byte(num)
		h := xxhash.Checksum64(bs)
		return int(h)
	}
	return int(f)
}
20300
func HashUint64(f func() hash.Hash64) func(uint64) uint64 {
	return func(u uint64) uint64 {
		b := [8]byte{}
		binary.BigEndian.PutUint64(b[:], u)
		h := f()
		h.Write(b[:])
		return h.Sum64()
	}
}
4332
func (txs Txs) IndexByHash(hash []byte) int {
	for i := range txs {
		if bytes.Equal(txs[i].Hash(), hash) {
			return i
		}
	}
	return -1
}
18161
func (api *API) GetBundle(tailTxHash Hash) (bundle.Bundle, error) {
	if err := Validate(ValidateTransactionHashes(tailTxHash)); err != nil {
		return nil, err
	}
	var err error
	bndl := bundle.Bundle{}
	bndl, err = api.TraverseBundle(tailTxHash, bndl)
	if err != nil {
		return nil, err
	}
	if err := bundle.ValidBundle(bndl); err != nil {
		return nil, err
	}
	return bndl, err
}
283519
func fnvHash64(data []byte) uint64 {
	hash := offset64
	for _, c := range data {
		hash *= prime64
		hash ^= uint64(c)
	}
	return hash
}
349894
func deriveHash_s(object string) uint64 {
	var h uint64
	for _, c := range object {
		h = 31*h + uint64(c)
	}
	return h
}
702010
func guiVersionAndHash(st *state.State, storage binarystorage.Storage) (vers, hash string, err error) {
	currentVers, err := st.GUIVersion()
	if errors.IsNotFound(err) {
		return "", "", errors.NotFoundf("Juju GUI")
	}
	if err != nil {
		return "", "", errors.Annotate(err, "cannot retrieve current GUI version")
	}
	metadata, err := storage.Metadata(currentVers.String())
	if err != nil {
		return "", "", errors.Annotate(err, "cannot retrieve GUI metadata")
	}
	return metadata.Version, metadata.SHA256, nil
}
412840
func fastHash(a int64, bs ...int64) int64 {
	buf := make([]byte, 8)
	hasher := fnv.New64a()
	w := func(v int64) {
		binary.LittleEndian.PutUint64(buf, uint64(v))
		if _, err := hasher.Write(buf); err != nil {
			panic(err)
		}
	}
	w(a)
	for _, b := range bs {
		w(b)
	}
	return int64(hasher.Sum64())
}
492190
func computeHash(msg []byte) ([]byte, error) {
	h, err := cryptosuite.GetDefault().Hash(msg, cryptosuite.GetSHA256Opts())
	if err != nil {
		return nil, errors.WithMessage(err, "failed to compute tls cert hash")
	}
	return h, err
}
765833
func normalizeBytes(number *builder.Builder) *builder.Builder {
	normalizedNumber := normalize(number.String())
	b := number.Bytes()
	copy(b[0:len(normalizedNumber)], []byte(normalizedNumber))
	return builder.NewBuilder(b)
}
701100
func DeleteCanonicalHash(db ethdb.Writer, number uint64) {
	if err := db.Delete(headerHashKey(number)); err != nil {
		log.Crit("Failed to delete number to hash mapping", "err", err)
	}
}
581653
func (h *HyperLogLog) calculateHash(data []byte) uint32 {
	h.hash.Write(data)
	sum := h.hash.Sum32()
	h.hash.Reset()
	return sum
}
370965
func ToHash(s []byte) Hash {
	if len(s) == 0 || len(s) > _Hash_maxLen {
		return 0
	}
	h := uint32(_Hash_hash0)
	for i := 0; i < len(s); i++ {
		h ^= uint32(s[i])
		h *= 16777619
	}
	if i := _Hash_table[h&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) {
		t := _Hash_text[i>>8 : i>>8+i&0xff]
		for i := 0; i < len(s); i++ {
			if t[i] != s[i] {
				goto NEXT
			}
		}
		return i
	}
NEXT:
	if i := _Hash_table[(h>>16)&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) {
		t := _Hash_text[i>>8 : i>>8+i&0xff]
		for i := 0; i < len(s); i++ {
			if t[i] != s[i] {
				return 0
			}
		}
		return i
	}
	return 0
}
43045
func sha1Hash(slices [][]byte) []byte {
	hsha1 := sha1.New()
	for _, slice := range slices {
		hsha1.Write(slice)
	}
	return hsha1.Sum(nil)
}
1258768
func (api *API) BroadcastBundle(tailTxHash Hash) ([]Trytes, error) {
	if err := Validate(ValidateTransactionHashes(tailTxHash)); err != nil {
		return nil, err
	}

	bndl, err := api.GetBundle(tailTxHash)
	if err != nil {
		return nil, err
	}
	trytes := transaction.MustFinalTransactionTrytes(bndl)
	return api.BroadcastTransactions(trytes...)
}