Exemple #1
0
func (i index) Decode(r io.Reader) error {
	idx := &idxfile.Idxfile{}

	d := idxfile.NewDecoder(r)
	if err := d.Decode(idx); err != nil {
		return err
	}

	for _, e := range idx.Entries {
		i[e.Hash] = int64(e.Offset)
	}

	return nil
}
Exemple #2
0
func getOffsetsFromIdx(r io.Reader) map[plumbing.Hash]int64 {
	idx := &idxfile.Idxfile{}
	err := idxfile.NewDecoder(r).Decode(idx)
	if err != nil {
		panic(err)
	}

	offsets := make(map[plumbing.Hash]int64)
	for _, e := range idx.Entries {
		offsets[e.Hash] = int64(e.Offset)
	}

	return offsets
}