Skip to content

Commit

Permalink
chore: rename params
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Nov 30, 2022
1 parent 1b34250 commit 4c8ab1a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion das/daser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (m getterStub) GetByHeight(_ context.Context, height uint64) (*header.Exten
DAH: &header.DataAvailabilityHeader{RowsRoots: make([][]byte, 0)}}, nil
}

func (m getterStub) GetRangeByHeight(ctx context.Context, from, to uint64) ([]*header.ExtendedHeader, error) {
func (m getterStub) GetRangeByHeight(ctx context.Context, from, amount uint64) ([]*header.ExtendedHeader, error) {
return nil, nil
}

Expand Down
8 changes: 4 additions & 4 deletions header/core/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ func (ce *Exchange) GetRangeByHeight(ctx context.Context, from, amount uint64) (
return headers, nil
}

func (ce *Exchange) GetVerifiedRange(ctx context.Context, origin *header.ExtendedHeader, amount uint64,
func (ce *Exchange) GetVerifiedRange(ctx context.Context, from *header.ExtendedHeader, amount uint64,
) ([]*header.ExtendedHeader, error) {
headers, err := ce.GetRangeByHeight(ctx, uint64(origin.Height)+1, amount)
headers, err := ce.GetRangeByHeight(ctx, uint64(from.Height)+1, amount)
if err != nil {
return nil, err
}

for _, h := range headers {
err := origin.VerifyAdjacent(h)
err := from.VerifyAdjacent(h)
if err != nil {
return nil, err
}
origin = h
from = h
}
return headers, nil
}
Expand Down
6 changes: 3 additions & 3 deletions header/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ type Getter interface {
// GetByHeight returns the ExtendedHeader corresponding to the given block height.
GetByHeight(context.Context, uint64) (*ExtendedHeader, error)

// GetRangeByHeight returns the given range [from:to) of ExtendedHeaders.
GetRangeByHeight(ctx context.Context, from, to uint64) ([]*ExtendedHeader, error)
// GetRangeByHeight returns the given range of ExtendedHeaders.
GetRangeByHeight(ctx context.Context, from, amount uint64) ([]*ExtendedHeader, error)

// GetVerifiedRange requests the header range from the provided ExtendedHeader and
// verifies that the returned headers are adjacent to each other.
GetVerifiedRange(ctx context.Context, origin *ExtendedHeader, to uint64) ([]*ExtendedHeader, error)
GetVerifiedRange(ctx context.Context, from *ExtendedHeader, amount uint64) ([]*ExtendedHeader, error)
}

// Head contains the behavior necessary for a component to retrieve
Expand Down
4 changes: 2 additions & 2 deletions header/local/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func (l *Exchange) GetRangeByHeight(ctx context.Context, origin, amount uint64)
return l.store.GetRangeByHeight(ctx, origin, origin+amount)
}

func (l *Exchange) GetVerifiedRange(ctx context.Context, origin *header.ExtendedHeader, amount uint64,
func (l *Exchange) GetVerifiedRange(ctx context.Context, from *header.ExtendedHeader, amount uint64,
) ([]*header.ExtendedHeader, error) {
return l.store.GetVerifiedRange(ctx, origin, uint64(origin.Height)+amount)
return l.store.GetVerifiedRange(ctx, from, uint64(from.Height)+amount)
}

func (l *Exchange) Get(ctx context.Context, hash bytes.HexBytes) (*header.ExtendedHeader, error) {
Expand Down
8 changes: 4 additions & 4 deletions header/p2p/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,23 @@ func (ex *Exchange) GetRangeByHeight(ctx context.Context, from, amount uint64) (
// that returned headers are correct against the passed one.
func (ex *Exchange) GetVerifiedRange(
ctx context.Context,
origin *header.ExtendedHeader,
from *header.ExtendedHeader,
amount uint64,
) ([]*header.ExtendedHeader, error) {
session := newSession(ex.ctx, ex.host, ex.peerTracker.peers(), ex.protocolID)
defer session.close()

headers, err := session.getRangeByHeight(ctx, uint64(origin.Height)+1, amount)
headers, err := session.getRangeByHeight(ctx, uint64(from.Height)+1, amount)
if err != nil {
return nil, err
}

for _, h := range headers {
err := origin.VerifyAdjacent(h)
err := from.VerifyAdjacent(h)
if err != nil {
return nil, err
}
origin = h
from = h
}
return headers, nil
}
Expand Down
4 changes: 2 additions & 2 deletions header/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ func (e *exchangeCountingHead) GetByHeight(ctx context.Context, u uint64) (*head
panic("implement me")
}

func (e *exchangeCountingHead) GetRangeByHeight(c context.Context, from, to uint64) ([]*header.ExtendedHeader, error) {
func (e *exchangeCountingHead) GetRangeByHeight(c context.Context, from, amount uint64) ([]*header.ExtendedHeader, error) {
panic("implement me")
}

func (e *exchangeCountingHead) GetVerifiedRange(c context.Context, from *header.ExtendedHeader, to uint64,
func (e *exchangeCountingHead) GetVerifiedRange(c context.Context, from *header.ExtendedHeader, amount uint64,
) ([]*header.ExtendedHeader, error) {
panic("implement me")
}

0 comments on commit 4c8ab1a

Please sign in to comment.