HISTORY_RETENTION_WINDOW- This is a setting on the RPC server which determines the range of ledgers retained by the RPC in a sliding window from latest on Stellar network. The default is to retain the latest 7 days worth of ledger data from the Stellar network.- Data Lake Integration - If the RPC has the Data Lake integration enabled then the range of ledgers available will be a minimum of RPC’s Retention Window and extends further back in history out to the larger range provided by the data lake.
Example SDK Usage
Prerequisites
- A URL of an RPC Server.
- Go 1.2x runtime
Code
A working example demonstrating programmatic usage of RPCLedgerBackend to print a stream of latest ledgers emitted from the Stellar Testnet Network. Note the additional usage of the RPC Go Client which uses the same RPC URL to get the latest ledger from the RPC server. This is used to prime our live streaming example to use the latest known ledger on RPC as the starting ledger when requesting the unbounded range. Prerequisites:- Create an empty directory
rpc-backendandcdinto the directory. - Run
go mod init example/rpc-backend - Run
go get github.com/stellar/go-stellar-sdk@latest - Copy this code snippet to
rpc_ledger_backend_demo.go
- Run
go mod tidy - Run
go run rpc_ledger_backend_demo.go