Simplified node status server to work with local ip

pull/515/head
kompotkot 2021-12-22 19:28:58 +00:00
rodzic cb41efb7b1
commit d9a8fd0b7d
3 zmienionych plików z 6 dodań i 21 usunięć

Wyświetl plik

@ -3,6 +3,7 @@ package cmd
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
@ -31,17 +32,13 @@ func (es *extendedServer) pingGethRoute(w http.ResponseWriter, req *http.Request
http.Error(w, http.StatusText(500), http.StatusInternalServerError)
return
}
var IPC_PATH string
if es.blockchain == "ethereum" {
IPC_PATH = settings.MOONSTREAM_NODE_ETHEREUM_IPC_PATH
} else if es.blockchain == "polygon" {
IPC_PATH = settings.MOONSTREAM_NODE_POLYGON_IPC_PATH
} else {
if es.blockchain != "ethereum" && es.blockchain != "polygon" {
log.Printf("Unaccepted blockchain type: %s", es.blockchain)
http.Error(w, http.StatusText(400), http.StatusBadRequest)
return
}
gethResponse, err := http.Post(IPC_PATH, "application/json",
MOONSTREAM_WEB3_PROVIDER_URI := fmt.Sprintf("http://%s:8545", settings.LOCAL_IPV4)
gethResponse, err := http.Post(MOONSTREAM_WEB3_PROVIDER_URI, "application/json",
bytes.NewBuffer(postBody))
if err != nil {
log.Printf("Unable to request geth, error: %s", err)

Wyświetl plik

@ -1,19 +1,10 @@
package settings
import (
"fmt"
"os"
)
// Geth configs
var MOONSTREAM_NODE_ETHEREUM_IPC_ADDR = os.Getenv("MOONSTREAM_NODE_ETHEREUM_IPC_ADDR")
var MOONSTREAM_NODE_ETHEREUM_IPC_PORT = os.Getenv("MOONSTREAM_NODE_ETHEREUM_IPC_PORT")
var MOONSTREAM_NODE_ETHEREUM_IPC_PATH = fmt.Sprintf("http://%s:%s", MOONSTREAM_NODE_ETHEREUM_IPC_ADDR, MOONSTREAM_NODE_ETHEREUM_IPC_PORT)
// Bor configs
var MOONSTREAM_NODE_POLYGON_IPC_ADDR = os.Getenv("MOONSTREAM_NODE_POLYGON_IPC_ADDR")
var MOONSTREAM_NODE_POLYGON_IPC_PORT = os.Getenv("MOONSTREAM_NODE_POLYGON_IPC_PORT")
var MOONSTREAM_NODE_POLYGON_IPC_PATH = fmt.Sprintf("http://%s:%s", MOONSTREAM_NODE_POLYGON_IPC_ADDR, MOONSTREAM_NODE_POLYGON_IPC_PORT)
var LOCAL_IPV4 = os.Getenv("AWS_LOCAL_IPV4")
// CORS
var MOONSTREAM_CORS_ALLOWED_ORIGINS = os.Getenv("MOONSTREAM_CORS_ALLOWED_ORIGINS")

Wyświetl plik

@ -1,5 +1,2 @@
export MOONSTREAM_NODE_ETHEREUM_IPC_ADDR="127.0.0.1"
export MOONSTREAM_NODE_ETHEREUM_IPC_PORT="8545"
export MOONSTREAM_NODE_POLYGON_IPC_ADDR="127.0.0.1"
export MOONSTREAM_NODE_POLYGON_IPC_PORT="8545"
export AWS_LOCAL_IPV4="<local_ip_of_instance>"
export MOONSTREAM_CORS_ALLOWED_ORIGINS="http://localhost:3000,https://moonstream.to,https://www.moonstream.to,https://alpha.moonstream.to"