v2: use a byte array for the characteristics bitfield
- Dominant language
- Go
- Stars
- 175
- Forks
- 54
- Avg merge
- 6d 5h
- Merged PRs (30d)
- 4
Description
Right now, characteristics is [as follows](https://pkg.go.dev/github.com/ipld/go-car/v2@v2.0.2#Characteristics):
```
type Characteristics struct {
Hi uint64
Lo uint64
}
```
And, as per the code, it encodes and decodes as little-endian.
If Go had a uint128 type, I'd definitely agree with this approach. For better or worse it doesn't, so using `encoding/binary.LittleEndian` doesn't save us complexity - we still have to choose between Hi and Lo.
I think it would be easier to use `[16]byte`, as proposed by @rvagg here: https://github.com/ipld/go-car/pull/239#discussion_r711861809
Then the logic should also become fairly straightforward to follow. For example, a "get bit" or "set bit" method on Characteristics would use `pos/8` to select an array index, and `pos%8` to select the bit within its byte.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.