diff --git a/CHANGELOG.md b/CHANGELOG.md index ec6ee7082..61bcaaad5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog +## Unreleased + +### Added +* `getHealth` now returns `latestLedgerCloseTime`, the unix timestamp (seconds) at which the latest ledger 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..5f2fe534d 100644 --- a/cmd/stellar-rpc/internal/integrationtest/health_test.go +++ b/cmd/stellar-rpc/internal/integrationtest/health_test.go @@ -19,4 +19,5 @@ 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.Greater(t, result.LatestLedgerCloseTime, int64(0)) } diff --git a/cmd/stellar-rpc/internal/methods/get_health.go b/cmd/stellar-rpc/internal/methods/get_health.go index 65f308bed..411ea27ee 100644 --- a/cmd/stellar-rpc/internal/methods/get_health.go +++ b/cmd/stellar-rpc/internal/methods/get_health.go @@ -45,6 +45,7 @@ func NewHealthCheck( result := protocol.GetHealthResponse{ Status: "healthy", LatestLedger: ledgerRange.LastLedger.Sequence, + LatestLedgerCloseTime: ledgerRange.LastLedger.CloseTime, OldestLedger: ledgerRange.FirstLedger.Sequence, LedgerRetentionWindow: retentionWindow, } diff --git a/go.mod b/go.mod index b2f97db58..de25c572a 100644 --- a/go.mod +++ b/go.mod @@ -148,3 +148,5 @@ require ( gopkg.in/tylerb/graceful.v1 v1.2.15 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/stellar/go-stellar-sdk => github.com/felixl256/go-stellar-sdk v0.6.1-0.20260619085442-8c1d885126d2 diff --git a/go.sum b/go.sum index 0315adfb4..c1d57cfef 100644 --- a/go.sum +++ b/go.sum @@ -173,6 +173,8 @@ github.com/fatih/structs v1.0.0 h1:BrX964Rv5uQ3wwS+KRUAJCBBw5PQmgJfJ6v4yly5QwU= github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/felixl256/go-stellar-sdk v0.6.1-0.20260619085442-8c1d885126d2 h1:zrflbi/ZqoowRGk428iNdWvLa5stAM9+uV71FVxbcOU= +github.com/felixl256/go-stellar-sdk v0.6.1-0.20260619085442-8c1d885126d2/go.mod h1:IkcqcrE9UQi7n/1y+MxKB+7qzdjG1T2kGOD7Ss8dqjw= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= @@ -429,8 +431,6 @@ 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.0 h1:NM2oqZJQup0QxnJMq6C8s4iIIhU6rHFX0rlsF3wh/Ho= -github.com/stellar/go-stellar-sdk v0.6.0/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=