Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
* Rename constructor of index by codec to a simpler name and update
docs.

* Use multicodec.Code as constant instead of wrappint unit64 every time.
  • Loading branch information
masih committed Jul 13, 2021
1 parent 6b55013 commit a319a1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions v2/blockstore/insertionindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

var (
errUnsupported = errors.New("not supported")
insertionIndexCodec = 0x300003
insertionIndexCodec = multicodec.Code(0x300003)
)

type (
Expand Down Expand Up @@ -112,7 +112,7 @@ func (ii *insertionIndex) Unmarshal(r io.Reader) error {
}

func (ii *insertionIndex) Codec() multicodec.Code {
return multicodec.Code(insertionIndexCodec)
return insertionIndexCodec
}

func (ii *insertionIndex) Load(rs []index.Record) error {
Expand All @@ -132,7 +132,7 @@ func newInsertionIndex() *insertionIndex {

// flatten returns a 'indexsorted' formatted index for more efficient subsequent loading
func (ii *insertionIndex) flatten() (index.Index, error) {
si, err := index.NewFromCodec(multicodec.CarIndexSorted)
si, err := index.New(multicodec.CarIndexSorted)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions v2/index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type (
}
)

// NewFromCodec constructs a new index corresponding to the given codec.
func NewFromCodec(codec multicodec.Code) (Index, error) {
// New constructs a new index corresponding to the given CAR index codec.
func New(codec multicodec.Code) (Index, error) {
switch codec {
case multicodec.CarIndexSorted:
return newSorted(), nil
Expand Down Expand Up @@ -96,7 +96,7 @@ func ReadFrom(r io.Reader) (Index, error) {
return nil, err
}
codec := multicodec.Code(code)
idx, err := NewFromCodec(codec)
idx, err := New(codec)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit a319a1b

Please sign in to comment.