diff --git a/das/daser.go b/das/daser.go index 911ca432ee..04a860f31a 100644 --- a/das/daser.go +++ b/das/daser.go @@ -150,7 +150,7 @@ func (d *DASer) Stop(ctx context.Context) error { func (d *DASer) sample(ctx context.Context, h *header.ExtendedHeader) error { // short-circuit if pruning is enabled and the header is outside the // availability window - if !d.isWithinSamplingWindow(h) { + if !pruner.IsWithinAvailabilityWindow(h.Time(), pruner.AvailabilityWindow(d.params.SamplingWindow)) { log.Debugw("skipping header outside sampling window", "height", h.Height(), "time", h.Time()) return nil @@ -171,14 +171,6 @@ func (d *DASer) sample(ctx context.Context, h *header.ExtendedHeader) error { return nil } -func (d *DASer) isWithinSamplingWindow(eh *header.ExtendedHeader) bool { - // if sampling window is not set, then all headers are within the window - if d.params.SamplingWindow == 0 { - return true - } - return pruner.IsWithinAvailabilityWindow(eh.Time(), pruner.AvailabilityWindow(d.params.SamplingWindow)) -} - // SamplingStats returns the current statistics over the DA sampling process. func (d *DASer) SamplingStats(ctx context.Context) (SamplingStats, error) { return d.sampler.stats(ctx) diff --git a/das/daser_test.go b/das/daser_test.go index 9eec6392cc..79c5ef6e76 100644 --- a/das/daser_test.go +++ b/das/daser_test.go @@ -24,6 +24,7 @@ import ( "github.com/celestiaorg/celestia-node/header" "github.com/celestiaorg/celestia-node/header/headertest" headerfraud "github.com/celestiaorg/celestia-node/header/headertest/fraud" + "github.com/celestiaorg/celestia-node/pruner" "github.com/celestiaorg/celestia-node/share" "github.com/celestiaorg/celestia-node/share/availability/full" "github.com/celestiaorg/celestia-node/share/availability/light" @@ -275,7 +276,11 @@ func TestDASer_SamplingWindow(t *testing.T) { eh := headertest.RandExtendedHeader(t) eh.RawHeader.Time = tt.timestamp - assert.Equal(t, tt.withinWindow, daser.isWithinSamplingWindow(eh)) + assert.Equal( + t, + tt.withinWindow, + pruner.IsWithinAvailabilityWindow(eh.Time(), pruner.AvailabilityWindow(daser.params.SamplingWindow)), + ) }) }