Skip to main content
BufferedStorageBackend is a ledger backend in Stellar ingest SDK that retrieves ledger metadata from a cloud-based data lake, typically populated by Galexie. While Galexie currently supports only GCS, BufferedStorageBackend is designed to work with any datastore that implements the datastore interface. It returns ledger metadata in XDR format.

Key Features

  • Parallel Downloads: Downloads multiple ledgers concurrently and buffers them in memory for fast access. This is particularly useful for fetching large historical ledger ranges.
  • Schema-Aware: Reads multi-ledger files based on the datastore schema, extracting one ledger at a time.
  • Automatic Retries: Handles request failures by retrying failed requests.
  • XDR Output: Returns ledger metadata in XDR format, enabling easy integration with other packages in ingest SDK (e.g., processors).

Prerequisites

Installation & Setup

  • Run Galexie to export ledger data to GCS cloud storage. Follow the Galexie admin guide for instructions on running Galexie.
  • For purposes of the example code, ensure access to a data lake populated by Galexie, configured as a GCS bucket. For instructions on creating a data lake, refer to the Galexie admin guide.

Configuration

Datastore Configuration

Configure the datastore to match the schema used during the Galexie export. This schema defines how many ledgers per file, and how many files per partition.
Example Configuration

BufferedStorageBackend Configuration

Configure the BufferedStorageBackend to control download concurrency, buffering, and retry behavior.
Example Configuration
You can specify these values individually or use the default configuration. The default settings automatically adjust the number of parallel download workers and buffer size based on the object size (ledger count per file). These values are based on empirical testing, but the optimal configuration may vary depending on hardware and network conditions.

Usage

BufferedStorageBackend can be used for batch processing a historical range of ledgers as well as for fetching new ledgers in real-time as they become available. Here is a sample code that uses BufferedStorageBackend for batch processing of historical ledger range.
For real-time streaming of new ledgers using BufferedStorageBackend, refer to the Ingestion Pipeline Code.