Source File
checksum.go
Belonging Package
github.com/dgraph-io/badger/v4/y
/** SPDX-FileCopyrightText: © 2017-2025 Istari Digital, Inc.* SPDX-License-Identifier: Apache-2.0*/package yimport (stderrors)// ErrChecksumMismatch is returned at checksum mismatch.var ErrChecksumMismatch = stderrors.New("checksum mismatch")// CalculateChecksum calculates checksum for data using ct checksum type.func ( []byte, pb.Checksum_Algorithm) uint64 {switch {case pb.Checksum_CRC32C:return uint64(crc32.Checksum(, CastagnoliCrcTable))case pb.Checksum_XXHash64:return xxhash.Sum64()default:panic("checksum type not supported")}}// VerifyChecksum validates the checksum for the data against the given expected checksum.func ( []byte, *pb.Checksum) error {:= CalculateChecksum(, .Algo)if != .Sum {return Wrapf(ErrChecksumMismatch, "actual: %d, expected: %d", , .Sum)}return nil}
![]() |
The pages are generated with Golds v0.8.4. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |