diff --git a/CHANGELOG.md b/CHANGELOG.md index ec6ee7082..218d1e646 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog +## Unreleased + +### Added +* `getHealth` now returns `latestLedgerCloseTime` and `oldestLedgerCloseTime`, the unix timestamps (seconds) at which the latest and oldest ledgers closed. This lets clients assess ledger freshness from the lightweight health endpoint without fetching full ledger metadata via `getLatestLedger` ([#797](https://github.com/stellar/stellar-rpc/pull/797)). + + ## [v27.0.0](https://github.com/stellar/stellar-rpc/compare/v26.0.1...v27.0.0) ### Breaking Changes diff --git a/cmd/stellar-rpc/internal/integrationtest/health_test.go b/cmd/stellar-rpc/internal/integrationtest/health_test.go index 21387865f..05d217c3d 100644 --- a/cmd/stellar-rpc/internal/integrationtest/health_test.go +++ b/cmd/stellar-rpc/internal/integrationtest/health_test.go @@ -19,4 +19,7 @@ func TestHealth(t *testing.T) { assert.Greater(t, result.OldestLedger, uint32(0)) assert.Greater(t, result.LatestLedger, uint32(0)) assert.GreaterOrEqual(t, result.LatestLedger, result.OldestLedger) + assert.Positive(t, result.LatestLedgerCloseTime) + assert.Positive(t, result.OldestLedgerCloseTime) + assert.GreaterOrEqual(t, result.LatestLedgerCloseTime, result.OldestLedgerCloseTime) } diff --git a/cmd/stellar-rpc/internal/methods/get_health.go b/cmd/stellar-rpc/internal/methods/get_health.go index 65f308bed..b57f72daa 100644 --- a/cmd/stellar-rpc/internal/methods/get_health.go +++ b/cmd/stellar-rpc/internal/methods/get_health.go @@ -45,7 +45,9 @@ func NewHealthCheck( result := protocol.GetHealthResponse{ Status: "healthy", LatestLedger: ledgerRange.LastLedger.Sequence, + LatestLedgerCloseTime: ledgerRange.LastLedger.CloseTime, OldestLedger: ledgerRange.FirstLedger.Sequence, + OldestLedgerCloseTime: ledgerRange.FirstLedger.CloseTime, LedgerRetentionWindow: retentionWindow, } return result, nil diff --git a/go.mod b/go.mod index 8569e5e20..fb6101884 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 - github.com/stellar/go-stellar-sdk v0.6.1-0.20260618191317-308407eca8c6 + github.com/stellar/go-stellar-sdk v0.6.1-0.20260624185910-fc9acb3f1ba6 github.com/stretchr/testify v1.11.1 ) diff --git a/go.sum b/go.sum index 554569825..262c6d611 100644 --- a/go.sum +++ b/go.sum @@ -429,8 +429,8 @@ github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= github.com/spiffe/go-spiffe/v2 v2.6.0 h1:l+DolpxNWYgruGQVV0xsfeya3CsC7m8iBzDnMpsbLuo= github.com/spiffe/go-spiffe/v2 v2.6.0/go.mod h1:gm2SeUoMZEtpnzPNs2Csc0D/gX33k1xIx7lEzqblHEs= -github.com/stellar/go-stellar-sdk v0.6.1-0.20260618191317-308407eca8c6 h1:UiPdd65wjndoURfq4+55UH1VCgCyCCdX0bMqr3LIo5k= -github.com/stellar/go-stellar-sdk v0.6.1-0.20260618191317-308407eca8c6/go.mod h1:IkcqcrE9UQi7n/1y+MxKB+7qzdjG1T2kGOD7Ss8dqjw= +github.com/stellar/go-stellar-sdk v0.6.1-0.20260624185910-fc9acb3f1ba6 h1:NL5m+E+Ln5/HAYenkgyr/kI5xmgGOQ+BMRFktjl1eIw= +github.com/stellar/go-stellar-sdk v0.6.1-0.20260624185910-fc9acb3f1ba6/go.mod h1:IkcqcrE9UQi7n/1y+MxKB+7qzdjG1T2kGOD7Ss8dqjw= github.com/stellar/go-xdr v0.0.0-20260529210834-0bf8f4956364 h1:gOKrfuWdZ92LFlv0TAwgZ7OsWKeBsOMDlGLyFgduI1w= github.com/stellar/go-xdr v0.0.0-20260529210834-0bf8f4956364/go.mod h1:If+U9Z1W5xU97VrOgJandQT+2dN7/iOpkCrxBJEyF80= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=