feat: 체인 클라이언트 멀티노드 페일오버 (SPOF 해결)
All checks were successful
Server CI/CD / lint-and-build (push) Successful in 21s
Server CI/CD / deploy (push) Successful in 56s

CHAIN_NODE_URLS 환경변수(쉼표 구분)로 복수 노드 지정 가능.
Client.Call()이 네트워크/HTTP 오류 시 다음 노드로 자동 전환.
RPC 레벨 오류(트랜잭션 실패 등)는 즉시 반환 (페일오버 미적용).
기존 CHAIN_NODE_URL 단일 설정은 하위 호환 유지.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-18 17:31:46 +09:00
parent e187a20e28
commit feb8ec96ad
3 changed files with 60 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ import (
"log"
"os"
"strconv"
"strings"
"github.com/joho/godotenv"
)
@@ -26,7 +27,10 @@ type Config struct {
GameDir string
// Chain integration
// ChainNodeURL은 단일 노드 설정용 (하위 호환).
// ChainNodeURLs는 CHAIN_NODE_URLS(쉼표 구분) 또는 ChainNodeURL에서 파생.
ChainNodeURL string
ChainNodeURLs []string
ChainID string
OperatorKeyHex string
WalletEncryptionKey string
@@ -74,6 +78,18 @@ func Load() {
SSAFYClientSecret: getEnv("SSAFY_CLIENT_SECRET", ""),
SSAFYRedirectURI: getEnv("SSAFY_REDIRECT_URI", ""),
}
// CHAIN_NODE_URLS (쉼표 구분) 우선, 없으면 CHAIN_NODE_URL 단일값 사용
if raw := getEnv("CHAIN_NODE_URLS", ""); raw != "" {
for _, u := range strings.Split(raw, ",") {
if u = strings.TrimSpace(u); u != "" {
C.ChainNodeURLs = append(C.ChainNodeURLs, u)
}
}
}
if len(C.ChainNodeURLs) == 0 {
C.ChainNodeURLs = []string{C.ChainNodeURL}
}
}
// WarnInsecureDefaults logs warnings for security-sensitive settings left at defaults.