From ed0fad01a2fc4ea4ef79bfefd300591581d0b14c Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Tue, 2 Dec 2025 13:03:50 -0500 Subject: [PATCH] Remove rocketscan --- README.md | 2 -- config.go | 7 ------- external/rocketscan.go | 47 ------------------------------------------ main.go | 1 - tasks/update_nodes.go | 38 +++------------------------------- 5 files changed, 3 insertions(+), 92 deletions(-) delete mode 100644 external/rocketscan.go diff --git a/README.md b/README.md index 4d3bc7c..c468a6d 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,6 @@ Usage of ./rescue-api: Address on which to listen for /metrics requests (default "0.0.0.0:9000") -rescue-proxy-api-addr string Address for the Rescue Proxy gRPC API - -rocketscan-api-url string - URL for the Rocketscan REST API -secure-grpc Whether to use gRPC over TLS (default true) ``` diff --git a/config.go b/config.go index 929c72c..13253fa 100644 --- a/config.go +++ b/config.go @@ -17,7 +17,6 @@ type config struct { CredentialSecret []byte DBPath string RescueProxyAPIAddr string - RocketscanAPIURL string AllowedOrigins []string SecureGRPC bool Debug bool @@ -52,7 +51,6 @@ Use 'dd if=/dev/urandom bs=4 count=8 | base64' if you need to generate a new sec ) dbPath := flag.String("db-path", "db.sqlite3", "sqlite3 database path") proxyAPIAddr := flag.String("rescue-proxy-api-addr", "", "Address for the Rescue Proxy gRPC API") - rocketscanAPIURL := flag.String("rocketscan-api-url", "", "URL for the Rocketscan REST API") allowedOrigins := flag.String("allowed-origins", "http://localhost:8080", "Comma-separated list of allowed CORS origins") secureGRPC := flag.Bool("secure-grpc", true, "Whether to use gRPC over TLS") debug := flag.Bool("debug", false, "Whether to enable verbose logging") @@ -74,10 +72,6 @@ Use 'dd if=/dev/urandom bs=4 count=8 | base64' if you need to generate a new sec return config{}, fmt.Errorf("invalid -rescue-proxy-api-addr argument: %v", err) } - if err := checkURL(*rocketscanAPIURL, "http", "https", ""); err != nil { - return config{}, fmt.Errorf("invalid -rocketscan-api-url argument: %v", err) - } - // Check that CORS allowed origins are valid. origins := strings.Split(*allowedOrigins, ",") if *allowedOrigins != "*" { @@ -94,7 +88,6 @@ Use 'dd if=/dev/urandom bs=4 count=8 | base64' if you need to generate a new sec CredentialSecret: secret, DBPath: *dbPath, RescueProxyAPIAddr: *proxyAPIAddr, - RocketscanAPIURL: *rocketscanAPIURL, AllowedOrigins: origins, SecureGRPC: *secureGRPC, Debug: *debug, diff --git a/external/rocketscan.go b/external/rocketscan.go deleted file mode 100644 index 4e43015..0000000 --- a/external/rocketscan.go +++ /dev/null @@ -1,47 +0,0 @@ -package external - -import ( - "encoding/json" - "net/url" - - "github.com/Rocket-Rescue-Node/rescue-api/util" -) - -const ( - rocketscanNodesPath = "/nodes/list/" -) - -type RocketscanAPIClient struct { - url string -} - -type RocketscanAPINode struct { - Address string `json:"address"` -} - -func NewRocketscanAPIClient(url string) *RocketscanAPIClient { - return &RocketscanAPIClient{url: url} -} - -func (c *RocketscanAPIClient) GetRocketPoolNodes() ([]RocketscanAPINode, error) { - url, err := url.JoinPath(c.url, rocketscanNodesPath) - if err != nil { - return nil, err - } - - // Limit the response size to 64MB (average response size is 3MB). - body, err := util.HTTPLimitedGet(url, 10*1024*1024) - if err != nil { - return nil, err - } - - nodes := make([]RocketscanAPINode, 0, 256) - if err := json.Unmarshal(body, &nodes); err != nil { - return nil, err - } - return nodes, nil -} - -func (c *RocketscanAPIClient) Close() error { - return nil -} diff --git a/main.go b/main.go index d41f942..31fb931 100644 --- a/main.go +++ b/main.go @@ -92,7 +92,6 @@ func main() { nodes := models.NewNodeRegistry() updateNodes := tasks.NewUpdateNodesTask( cfg.RescueProxyAPIAddr, - cfg.RocketscanAPIURL, nodes, cfg.SecureGRPC, logger, diff --git a/tasks/update_nodes.go b/tasks/update_nodes.go index fde326e..4d458eb 100644 --- a/tasks/update_nodes.go +++ b/tasks/update_nodes.go @@ -10,10 +10,9 @@ import ( ) // UpdateNodesTask periodically updates the registry of known Rocket Pool nodes. -// It uses the Rescue Proxy (primary) and Rocketscan (fallback) APIs to retrieve the list of nodes. +// It uses the Rescue Proxy to retrieve the list of nodes. type UpdateNodesTask struct { rescueProxyAddr string - rocketscanURL string nodes *models.NodeRegistry done chan bool secureGRPC bool @@ -21,14 +20,13 @@ type UpdateNodesTask struct { } func NewUpdateNodesTask( - proxy, rocketscan string, + proxy string, nodes *models.NodeRegistry, secureGRPC bool, logger *zap.Logger, ) *UpdateNodesTask { return &UpdateNodesTask{ proxy, - rocketscan, nodes, make(chan bool), secureGRPC, @@ -59,29 +57,6 @@ func (t *UpdateNodesTask) updateUsingRescueProxy() error { return nil } -// updateUsingRocketscan updates the node registry using the Rocketscan API. -func (t *UpdateNodesTask) updateUsingRocketscan() error { - src := "rocketscan" - t.logger.Info("Updating Rocket Pool node registry...", zap.String("source", src)) - - rocketscanAPI := external.NewRocketscanAPIClient(t.rocketscanURL) - defer rocketscanAPI.Close() - nodes, err := rocketscanAPI.GetRocketPoolNodes() - if err != nil { - t.logger.Warn("Failed to update node registry", zap.String("source", src), zap.Error(err)) - return err - } - newList := make([]models.NodeID, 0, len(nodes)) - for _, n := range nodes { - newList = append(newList, common.HexToAddress(n.Address)) - } - t.nodes.Add(newList) - - t.logger.Info("Node registry successfully updated", zap.String("source", src)) - - return nil -} - func (t *UpdateNodesTask) Run() { ticker := time.NewTicker(time.Duration(1) * time.Second) defer ticker.Stop() @@ -93,15 +68,8 @@ func (t *UpdateNodesTask) Run() { case <-ticker.C: // Try to update using the Rescue Proxy API. err := t.updateUsingRescueProxy() - // If that fails, try to update using the Rocketscan API. - if err != nil { - err = t.updateUsingRocketscan() - } - if err != nil { // If both sources fail, try again quickly. + if err != nil { // If sources fail, try again quickly. ticker.Reset(time.Duration(30) * time.Second) - } else { // If at least one source succeeds, sleep for a longer time. - ticker.Reset(time.Duration(300) * time.Second) - t.nodes.LastUpdated = time.Now() } } }