blob: 5aa122a99285e0f04c3171df5956b3e054c3bb7f (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package bloom
import "encoding/binary"
// 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,
}
return settings, nil
}
|