diff --git a/exp/services/ledgerexporter/internal/config.go b/exp/services/ledgerexporter/internal/config.go index 2f6589a720..bab184bdc7 100644 --- a/exp/services/ledgerexporter/internal/config.go +++ b/exp/services/ledgerexporter/internal/config.go @@ -182,10 +182,7 @@ func (config *Config) adjustLedgerRange() { // Align the end ledger (for bounded cases) to the nearest "LedgersPerFile" boundary. if config.EndLedger != 0 { - // Add an extra batch only if "LedgersPerFile" is greater than 1 and the end ledger doesn't fall on the boundary. - if config.LedgerBatchConfig.LedgersPerFile > 1 && config.EndLedger%config.LedgerBatchConfig.LedgersPerFile != 0 { - config.EndLedger = (config.EndLedger/config.LedgerBatchConfig.LedgersPerFile + 1) * config.LedgerBatchConfig.LedgersPerFile - } + config.EndLedger = config.LedgerBatchConfig.GetSequenceNumberEndBoundary(config.EndLedger) } logger.Infof("Computed effective export boundary ledger range: start=%d, end=%d", config.StartLedger, config.EndLedger) diff --git a/exp/services/ledgerexporter/internal/config_test.go b/exp/services/ledgerexporter/internal/config_test.go index 86f6cfb5b3..133165072f 100644 --- a/exp/services/ledgerexporter/internal/config_test.go +++ b/exp/services/ledgerexporter/internal/config_test.go @@ -5,8 +5,9 @@ import ( "fmt" "testing" - "github.com/stellar/go/historyarchive" "github.com/stretchr/testify/require" + + "github.com/stellar/go/historyarchive" ) func TestNewConfigResumeEnabled(t *testing.T) { @@ -154,7 +155,7 @@ func TestAdjustedLedgerRangeBoundedMode(t *testing.T) { start: 0, end: 1, expectedStart: 2, - expectedEnd: 10, + expectedEnd: 9, }, { name: "Round down start ledger and round up end ledger, 15 ledgers per file ", @@ -162,7 +163,7 @@ func TestAdjustedLedgerRangeBoundedMode(t *testing.T) { start: 4, end: 10, expectedStart: 2, - expectedEnd: 15, + expectedEnd: 14, }, { name: "Round down start ledger and round up end ledger, 64 ledgers per file ", @@ -170,7 +171,7 @@ func TestAdjustedLedgerRangeBoundedMode(t *testing.T) { start: 400, end: 500, expectedStart: 384, - expectedEnd: 512, + expectedEnd: 511, }, { name: "No change, 64 ledger per file", @@ -178,7 +179,7 @@ func TestAdjustedLedgerRangeBoundedMode(t *testing.T) { start: 64, end: 128, expectedStart: 64, - expectedEnd: 128, + expectedEnd: 191, }, }