diff options
| author | 2026-03-10 13:30:48 +0800 | |
|---|---|---|
| committer | 2026-03-10 13:30:48 +0800 | |
| commit | 73e602a5c2c766caba59948e91c11122653705ec (patch) | |
| tree | 57951a4275dd90c2b3953e5b4bf3c9a7bd09b84a /format/commitgraph/bloom/settings.go | |
| parent | *: Move sideband64k and pktline to protocol/ (diff) | |
| signature | No signature | |
commitgraph: Move out of format/
Diffstat (limited to 'format/commitgraph/bloom/settings.go')
| -rw-r--r-- | format/commitgraph/bloom/settings.go | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/format/commitgraph/bloom/settings.go b/format/commitgraph/bloom/settings.go deleted file mode 100644 index 764653bd..00000000 --- a/format/commitgraph/bloom/settings.go +++ /dev/null @@ -1,50 +0,0 @@ -package bloom - -import ( - "encoding/binary" - - "codeberg.org/lindenii/furgit/internal/intconv" -) - -// Settings describe the changed-paths Bloom filter parameters stored in -// commit-graph BDAT chunks. -// -// Obviously, they must match the repository's commit-graph settings to -// interpret filters correctly. -type Settings struct { - HashVersion uint32 - NumHashes uint32 - BitsPerEntry uint32 - MaxChangePaths uint32 -} - -// ParseSettings reads Bloom filter settings from a BDAT chunk header. -func ParseSettings(bdat []byte) (*Settings, error) { - if len(bdat) < DataHeaderSize { - return nil, ErrInvalid - } - - settings := &Settings{ - HashVersion: binary.BigEndian.Uint32(bdat[0:4]), - NumHashes: binary.BigEndian.Uint32(bdat[4:8]), - BitsPerEntry: binary.BigEndian.Uint32(bdat[8:12]), - MaxChangePaths: DefaultMaxChange, - } - - switch settings.HashVersion { - case 1, 2: - default: - return nil, ErrInvalid - } - - if settings.NumHashes == 0 { - return nil, ErrInvalid - } - - _, err := intconv.Uint32ToInt(settings.NumHashes) - if err != nil { - return nil, ErrInvalid - } - - return settings, nil -} |
