diff --git a/go.mod b/go.mod index c5c9c51e..e87fbc1a 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.17.0 - github.com/stellar/go v0.0.0-20240419044405-2d7308b67c07 + github.com/stellar/go v0.0.0-20240419222646-3a79646669ab github.com/stretchr/testify v1.9.0 ) diff --git a/go.sum b/go.sum index b247522d..3d6f1fa8 100644 --- a/go.sum +++ b/go.sum @@ -298,6 +298,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/stellar/go v0.0.0-20240419044405-2d7308b67c07 h1:AgxlbRmsFAc9VaOLj29K9RpsSmlmtJ0KCVnGxV7bUwo= github.com/stellar/go v0.0.0-20240419044405-2d7308b67c07/go.mod h1:ckzsX0B0qfTMVZQJtPELJLs7cJ6xXMYHPVLyIsReGsU= +github.com/stellar/go v0.0.0-20240419222646-3a79646669ab h1:+uTCn/DrOc1cXugQ8PKZPAkZS3KWeHk5f2aKk9jdrDs= +github.com/stellar/go v0.0.0-20240419222646-3a79646669ab/go.mod h1:ckzsX0B0qfTMVZQJtPELJLs7cJ6xXMYHPVLyIsReGsU= github.com/stellar/go-xdr v0.0.0-20231122183749-b53fb00bcac2 h1:OzCVd0SV5qE3ZcDeSFCmOWLZfEWZ3Oe8KtmSOYKEVWE= github.com/stellar/go-xdr v0.0.0-20231122183749-b53fb00bcac2/go.mod h1:yoxyU/M8nl9LKeWIoBrbDPQ7Cy+4jxRcWcOayZ4BMps= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/internal/utils/main.go b/internal/utils/main.go index b6bb39c1..a91e6ef2 100644 --- a/internal/utils/main.go +++ b/internal/utils/main.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "math/big" + "net/url" "time" "github.com/spf13/pflag" @@ -657,8 +658,7 @@ func GetEnvironmentDetails(isTest bool, isFuture bool, datastoreUrl string) (det details.NetworkPassphrase = network.TestNetworkPassphrase details.ArchiveURLs = testArchiveURLs details.BinaryPath = "/usr/bin/stellar-core" - details.CoreConfig = "/etl/docker/stellar-core_testnet.cfg" - // TODO: change exporter-test to the real bucket whatever that is + details.CoreConfig = "/etl/docker/stellar-core_testnet.cfg" details.StorageURL = datastoreUrl return details } else if isFuture { @@ -666,7 +666,7 @@ func GetEnvironmentDetails(isTest bool, isFuture bool, datastoreUrl string) (det details.NetworkPassphrase = "Test SDF Future Network ; October 2022" details.ArchiveURLs = futureArchiveURLs details.BinaryPath = "/usr/bin/stellar-core" - details.CoreConfig = "/etl/docker/stellar-core_futurenet.cfg" + details.CoreConfig = "/etl/docker/stellar-core_futurenet.cfg" details.StorageURL = datastoreUrl return details } else { @@ -747,6 +747,7 @@ func LedgerEntryToLedgerKeyHash(ledgerEntry xdr.LedgerEntry) string { // CreateLedgerBackend creates a ledger backend using captive core or datastore // Defaults to using datastore func CreateLedgerBackend(ctx context.Context, useCaptiveCore bool, env EnvironmentDetails) (ledgerbackend.LedgerBackend, error) { + // Create ledger backend from captive core if useCaptiveCore { backend, err := env.CreateCaptiveCoreBackend() if err != nil { @@ -755,11 +756,29 @@ func CreateLedgerBackend(ctx context.Context, useCaptiveCore bool, env Environme return backend, nil } - backend, err := ledgerbackend.NewCloudStorageBackend(ctx, env.StorageURL) + // Create ledger backend from datastore + fileConfig := ledgerbackend.LCMFileConfig{ + StorageURL: env.StorageURL, + FileSuffix: ".xdr.gz", + LedgersPerFile: 1, + FilesPerPartition: 64000, + } + + parsed, err := url.Parse(env.StorageURL) if err != nil { return nil, err } - return backend, nil + + // Using the GCS datastore backend + if parsed.Scheme == "gcs" { + backend, err := ledgerbackend.NewGCSBackend(ctx, fileConfig) + if err != nil { + return nil, err + } + return backend, nil + } + + return nil, errors.New("no valid ledgerbackend selected") } func LedgerKeyToLedgerKeyHash(ledgerKey xdr.LedgerKey) string {