mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
Fix/hway db driver (#1198)
* fix/hway-db-driver * fix/hway-db-driver * chore(scripts): add tx indexer and psql connection to test * fix(scripts): make testnet setup more robust and configurable
This commit is contained in:
+21
-3
@@ -5,6 +5,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/common"
|
||||
"github.com/onsonr/sonr/pkg/gateway"
|
||||
@@ -21,6 +22,7 @@ var (
|
||||
sonrRPCURL string // Sonr RPC URL (default localhost:26657)
|
||||
|
||||
psqlHost string // PostgresSQL Host Flag
|
||||
psqlPort string // PostgresSQL Port Flag
|
||||
psqlUser string // PostgresSQL User Flag
|
||||
psqlPass string // PostgresSQL Password Flag
|
||||
psqlDB string // PostgresSQL Database Flag
|
||||
@@ -61,8 +63,9 @@ func rootCmd() *cobra.Command {
|
||||
cmd.Flags().StringVar(&sonrGrpcURL, "sonr-grpc-url", "localhost:9090", "Sonr gRPC URL")
|
||||
cmd.Flags().StringVar(&sonrRPCURL, "sonr-rpc-url", "localhost:26657", "Sonr RPC URL")
|
||||
cmd.Flags().StringVar(&psqlHost, "psql-host", "localhost", "PostgresSQL Host")
|
||||
cmd.Flags().StringVar(&psqlUser, "psql-user", "postgres", "PostgresSQL User")
|
||||
cmd.Flags().StringVar(&psqlPass, "psql-pass", "postgres", "PostgresSQL Password")
|
||||
cmd.Flags().StringVar(&psqlPort, "psql-port", "5432", "PostgresSQL Port")
|
||||
cmd.Flags().StringVar(&psqlUser, "psql-user", "highway_user", "PostgresSQL User")
|
||||
cmd.Flags().StringVar(&psqlPass, "psql-pass", "highway_password123", "PostgresSQL Password")
|
||||
cmd.Flags().StringVar(&psqlDB, "psql-db", "highway", "PostgresSQL Database")
|
||||
return cmd
|
||||
}
|
||||
@@ -71,5 +74,20 @@ func formatPsqlDSN() string {
|
||||
if psqlHost == "" {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable", psqlHost, psqlUser, psqlPass, psqlDB)
|
||||
|
||||
host := psqlHost
|
||||
port := "5432"
|
||||
|
||||
if parts := strings.Split(psqlHost, ":"); len(parts) == 2 {
|
||||
host = parts[0]
|
||||
port = parts[1]
|
||||
}
|
||||
|
||||
dsn := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=verify-full",
|
||||
host, port, psqlUser, psqlPass, psqlDB)
|
||||
|
||||
log.Printf("Attempting to connect to PostgreSQL with DSN: host=%s port=%s user=%s dbname=%s",
|
||||
host, port, psqlUser, psqlDB) // Don't log the password
|
||||
|
||||
return dsn
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
config "github.com/onsonr/sonr/internal/config/hway"
|
||||
"github.com/onsonr/sonr/internal/models/drivers/hwayorm"
|
||||
hwayorm "github.com/onsonr/sonr/pkg/gateway/orm"
|
||||
)
|
||||
|
||||
// main is the entry point for the application
|
||||
|
||||
Reference in New Issue
Block a user