@@ -2,7 +2,6 @@ package crib
22
33import (
44 "fmt"
5- "net/http"
65 "os"
76 "strconv"
87
@@ -26,7 +25,6 @@ const (
2625 DefaultSimulatedPrivateKey = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
2726 // DefaultSimulatedNetworkChainID is a default chainID we use for Geth/Hardhat/Anvil
2827 DefaultSimulatedNetworkChainID = 1337
29- HostHeader = "X-Original-Host"
3028)
3129
3230// ConnectionVars common K8s connection vars
@@ -40,16 +38,13 @@ type ConnectionVars struct {
4038// CoreDONConnectionConfig Chainlink DON connection config
4139type CoreDONConnectionConfig struct {
4240 * ConnectionVars
43- PrivateKeys []string
44- NodeURLs []string
45- NodeInternalDNS []string
46- NodeHeaders []map [string ]string
47- BlockchainNodeHeaders http.Header
48- MockserverHeaders map [string ]string
49- ChainID int64
50- NetworkWSURL string
51- NetworkHTTPURL string
52- MockserverURL string
41+ PrivateKeys []string
42+ NodeURLs []string
43+ NodeInternalDNS []string
44+ ChainID int64
45+ NetworkWSURL string
46+ NetworkHTTPURL string
47+ MockserverURL string
5348}
5449
5550// CoreDONSimulatedConnection returns all vars required to connect to core DON Simulated CRIB
@@ -62,48 +57,40 @@ func CoreDONSimulatedConnection() (*CoreDONConnectionConfig, error) {
6257 var conn * CoreDONConnectionConfig
6358 clNodeURLs := make ([]string , 0 )
6459 clNodesInternalDNS := make ([]string , 0 )
65- clNodesHeaders := make ([]map [string ]string , 0 )
6660 for i := 1 ; i <= vars .Nodes ; i ++ {
6761 clNodesInternalDNS = append (clNodesInternalDNS , fmt .Sprintf (InternalNodeDNSTemplate , i ))
68- clNodesHeaders = append (clNodesHeaders , map [string ]string {
69- HostHeader : fmt .Sprintf ("%s-node%d%s" , vars .Namespace , i , vars .IngressSuffix ),
70- })
7162 }
7263 conn = & CoreDONConnectionConfig {
7364 ConnectionVars : vars ,
7465 PrivateKeys : []string {DefaultSimulatedPrivateKey },
7566 NodeURLs : clNodeURLs ,
7667 NodeInternalDNS : clNodesInternalDNS ,
77- NodeHeaders : clNodesHeaders ,
78- BlockchainNodeHeaders : http.Header {
79- HostHeader : []string {fmt .Sprintf ("%s-geth-%d-http%s" , vars .Namespace , DefaultSimulatedNetworkChainID , vars .IngressSuffix )},
80- },
81- MockserverHeaders : map [string ]string {
82- HostHeader : fmt .Sprintf ("%s-mockserver%s" , vars .Namespace , vars .IngressSuffix ),
83- },
84- ChainID : DefaultSimulatedNetworkChainID ,
68+ ChainID : DefaultSimulatedNetworkChainID ,
8569 }
8670 // GAP connection
87- gapURL := os .Getenv ("GAP_URL" )
88- if gapURL == "" {
71+ gapEnabled := os .Getenv ("GAP_ENABLED" )
72+ if gapEnabled == "true" {
73+ logging .L .Info ().Msg ("Connecting to CRIB using GAP" )
74+ for i := 1 ; i <= vars .Nodes ; i ++ {
75+ conn .NodeURLs = append (conn .NodeURLs , fmt .Sprintf ("https://gap-%s-node%d.public%s" , vars .Namespace , i , vars .IngressSuffix ))
76+ }
77+ conn .NetworkWSURL = fmt .Sprintf ("wss://gap-%s-geth-%d-ws.public%s" , vars .Namespace , DefaultSimulatedNetworkChainID , vars .IngressSuffix )
78+ conn .NetworkHTTPURL = fmt .Sprintf ("https://gap-%s-geth-%d-http.public%s" , vars .Namespace , DefaultSimulatedNetworkChainID , vars .IngressSuffix )
79+ conn .MockserverURL = fmt .Sprintf ("https://gap-%s-mockserver.public%s" , vars .Namespace , vars .IngressSuffix )
80+ } else {
8981 logging .L .Info ().Msg ("Connecting to CRIB locally" )
9082 for i := 1 ; i <= vars .Nodes ; i ++ {
9183 conn .NodeURLs = append (conn .NodeURLs , fmt .Sprintf ("https://%s-node%d%s" , vars .Namespace , i , vars .IngressSuffix ))
9284 }
9385 conn .NetworkWSURL = fmt .Sprintf (IngressNetworkWSURLTemplate , vars .Namespace , DefaultSimulatedNetworkChainID , vars .IngressSuffix )
9486 conn .NetworkHTTPURL = fmt .Sprintf (IngressNetworkHTTPURLTemplate , vars .Namespace , DefaultSimulatedNetworkChainID , vars .IngressSuffix )
9587 conn .MockserverURL = fmt .Sprintf (MockserverCRIBTemplate , vars .Namespace , vars .IngressSuffix )
96- } else {
97- logging .L .Info ().Msg ("Connecting to CRIB using GAP" )
98- for i := 1 ; i <= vars .Nodes ; i ++ {
99- conn .NodeURLs = append (conn .NodeURLs , gapURL )
100- }
101- conn .NetworkWSURL = gapURL
102- conn .NetworkHTTPURL = gapURL
103- conn .MockserverURL = gapURL
88+
10489 }
90+
10591 logging .L .Debug ().Any ("ConnectionInfo" , conn ).Msg ("CRIB connection info" )
10692 return conn , nil
93+
10794}
10895
10996// ReadCRIBVars read CRIB environment variables
0 commit comments