Parse dependencies
Dependencies
- [2]
7VEHGTEYSwitch from reading text format to reading binary format. - [*]
EKAB33DHStart using some parser combinators - [*]
PHRWK7NKParse change headers
Change contents
- edit in combinators.go at line 268
}func uint32LE(input []byte) ([]byte, uint32, error) {if len(input) < 4 {return input, 0, fmt.Errorf("need 4 bytes to parse a 32-bit integer; only got %d", len(input))}return input[4:], binary.LittleEndian.Uint32(input), nil - edit in combinators.go at line 361
}}func take(n int) parser[[]byte] {return func(data []byte) ([]byte, []byte, error) {if n > len(data) {return data, nil, io.ErrUnexpectedEOF}return data[n:], data[:n], nil - edit in change_test.go at line 22[5.701][5.1094]
Dependencies: []Hash{Hash{0xe7, 0x82, 0xb1, 0xd7, 0xe4, 0x17, 0x64, 0xe4, 0xfe, 0x45, 0x2d, 0x6f, 0x24, 0x22, 0x40, 0x26, 0x16, 0x12, 0xb7, 0xf, 0x42, 0x70, 0xd9, 0xac, 0xd8, 0x4e, 0x5a, 0x82, 0xea, 0x85, 0xab, 0x57}},ExtraKnown: []Hash{},Metadata: []byte{}, - edit in change_test.go at line 34[2.9330][5.1402]
}}func TestHashBase32(t *testing.T) {hs := "CB7A3PP3XC6JY3QYUUNB4WCXGNFJMHTTH54MBAWBUVQL7TTHWBBQC"hash, err := HashFromBase32(hs)if err != nil {t.Fatalf("error parsing hash: %v", err) - edit in change_test.go at line 43[5.1405][5.1405]
if hash.String() != hs {t.Fatalf("got %s, want %s", hash.String(), hs)} - edit in change.go at line 5
"encoding/base32" - replacement in change.go at line 15
Version uint64Message stringDescription stringTimestamp time.TimeAuthors []map[string]stringVersion uint64Message stringDescription stringTimestamp time.TimeAuthors []map[string]stringDependencies []HashExtraKnown []HashMetadata []byte}type Hash [32]bytevar base32Encoding = base32.StdEncoding.WithPadding(base32.NoPadding)func (h Hash) String() string {return base32Encoding.EncodeToString(append(h[:], 1)) - edit in change.go at line 33
func HashFromBase32(b32 string) (Hash, error) {b, err := base32Encoding.DecodeString(b32)if err != nil {return Hash{}, err}if len(b) != 33 {return Hash{}, fmt.Errorf("expected 33 bytes, got %d", len(b))}if b[32] != 1 {return Hash{}, fmt.Errorf("expected Blake3 hash, got type %d", b[32])}return Hash(b[:32]), nil} - replacement in change.go at line 65
zr, err := zstd.NewReader(br)zr, err := zstd.NewReader(bytes.NewReader(data[binary.Size(offsets{}):off.UnhashedOffset])) - edit in change.go at line 94
- edit in change.go at line 99
- edit in change.go at line 107
- edit in change.go at line 114
- edit in change.go at line 116
if err != nil {return err}data, c.Dependencies, err = vec(deserializeHash)(data) - replacement in change.go at line 125
//TODOdata, c.ExtraKnown, err = vec(deserializeHash)(data)if err != nil {return err}data, c.Metadata, err = lengthData(uint64LE)(data)if err != nil {return err} - edit in change.go at line 138
func deserializeHash(data []byte) ([]byte, Hash, error) {data, tag, err := uint32LE(data)if err != nil {return data, Hash{}, err}if tag == 0 {return data, Hash{}, nil}if tag != 1 {return data, Hash{}, fmt.Errorf("bad tag for Hash, expected 0 or 1, got %d", tag)}data, b, err := take(32)(data)if err != nil {return data, Hash{}, err}return data, Hash(b), nil}