prysm-pulse/tools/contract-addr/main.go
Preston Van Loon 7cc32c4dda
Various code inspection resolutions (#7438)
* remove unused code

* remove defer use in loop

* Remove unused methods and constants

* gofmt and gaz

* nilness check

* remove unused args

* Add TODO for refactoring subscribeWithBase to remove unused arg. It seems too involved to include in this sweeping PR. https://github.com/prysmaticlabs/prysm/issues/7437

* replace empty slice declaration

* Remove unnecessary type conversions

* remove redundant type declaration

* rename receivers to be consistent

* Remove bootnode query tool. It is now obsolete by discv5

* Remove relay node. It is no longer used or supported

* Revert "Remove relay node. It is no longer used or supported"

This reverts commit 4bd7717334dad85ef4766ed9bc4da711fb5fa810.

* Delete unused test directory

* Delete unsupported gcp startup script

* Delete old k8s script

* build fixes

* fix build

* go mod tidy

* revert slasher/db/kv/block_header.go

* fix build

* remove redundant nil check

* combine func args

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
2020-10-12 08:11:05 +00:00

45 lines
934 B
Go

/**
* This tool exists to serve currently configured contract address in k8s.
* It reads the contract address from a plain text file as provided by etcd.
*/
package main
import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
_ "github.com/prysmaticlabs/prysm/shared/maxprocs"
)
var address = flag.String("address-path", "", "The file path to the plain text file with the contract address")
func main() {
flag.Parse()
if *address == "" {
panic("Contract address filepath not set")
}
fmt.Println("Starting on port 8080")
log.Fatal(http.ListenAndServe(":8080", &handler{}))
}
type handler struct{}
func (h *handler) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
dat, err := ioutil.ReadFile(*address)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
_, err = io.WriteString(w, string(dat))
if err != nil {
fmt.Printf("Failed to write response: %v", err)
}
}