Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
Expand Down
7 changes: 0 additions & 7 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type config struct {
CredentialSecret []byte
DBPath string
RescueProxyAPIAddr string
RocketscanAPIURL string
AllowedOrigins []string
SecureGRPC bool
Debug bool
Expand Down Expand Up @@ -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")
Expand All @@ -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 != "*" {
Expand All @@ -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,
Expand Down
47 changes: 0 additions & 47 deletions external/rocketscan.go

This file was deleted.

1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func main() {
nodes := models.NewNodeRegistry()
updateNodes := tasks.NewUpdateNodesTask(
cfg.RescueProxyAPIAddr,
cfg.RocketscanAPIURL,
nodes,
cfg.SecureGRPC,
logger,
Expand Down
38 changes: 3 additions & 35 deletions tasks/update_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@ 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
logger *zap.Logger
}

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,
Expand Down Expand Up @@ -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()
Expand All @@ -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()
}
}
}
Expand Down
Loading