Skip to content

Commit

Permalink
feat(torch): fix error
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Ramon Mañes <jose@celestia.org>
  • Loading branch information
tty47 committed Oct 25, 2023
1 parent 8e61ef6 commit 1b5054a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 31 deletions.
5 changes: 0 additions & 5 deletions pkg/http/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ func Router(r *mux.Router, cfg config.MutualPeersConfig) *mux.Router {
Gen(w, r, cfg)
}).Methods("POST")

// comment this endpoint for now.
//s.HandleFunc("/genAll", func(w http.ResponseWriter, r *http.Request) {
// GenAll(w, r, cfg)
//}).Methods("POST")

// metrics
r.Handle("/metrics", promhttp.Handler())

Expand Down
47 changes: 24 additions & 23 deletions pkg/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func GetHttpPort() string {
// Ensure that the provided port is a valid numeric value
_, err := strconv.Atoi(port)
if err != nil {
log.Error("Invalid HTTP_PORT value: %v. Using default port 8080")
log.Error("Invalid HTTP_PORT [", os.Getenv("HTTP_PORT"), "] ,using default port 8080")
return "8080"
}

Expand Down Expand Up @@ -115,25 +115,26 @@ func GenerateHashMetrics(cfg config.MutualPeersConfig, err error) bool {
return false
}

// RegisterMetrics generates and registers the metrics for all nodes in the configuration.
func RegisterMetrics(cfg config.MutualPeersConfig) error {
log.Info("Generating initial metrics for all the nodes...")

var nodeNames []string

// Adding nodes from config to register the initial metrics
for _, n := range cfg.MutualPeers {
for _, no := range n.Peers {
nodeNames = append(nodeNames, no.NodeName)
}
}

// Generate the metrics for all nodes
_, err := nodes.GenerateAllTrustedPeersAddr(cfg, nodeNames)
if err != nil {
log.Errorf("Error GenerateAllTrustedPeersAddr: %v", err)
return err
}

return nil
}
//
//// RegisterMetrics generates and registers the metrics for all nodes in the configuration.
//func RegisterMetrics(cfg config.MutualPeersConfig) error {
// log.Info("Generating initial metrics for all the nodes...")
//
// var nodeNames []string
//
// // Adding nodes from config to register the initial metrics
// for _, n := range cfg.MutualPeers {
// for _, no := range n.Peers {
// nodeNames = append(nodeNames, no.NodeName)
// }
// }
//
// // Generate the metrics for all nodes
// _, err := nodes.GenerateAllTrustedPeersAddr(cfg, nodeNames)
// if err != nil {
// log.Errorf("Error GenerateAllTrustedPeersAddr: %v", err)
// return err
// }
//
// return nil
//}
3 changes: 1 addition & 2 deletions pkg/nodes/consensus_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package nodes

import (
"github.com/celestiaorg/torch/config"
"reflect"
"testing"

"github.com/celestiaorg/torch/config"
)

func TestSetConsNodeDefault(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/nodes/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func SetupDANodeWithConnections(peer config.Peer) error {

// validate the MA, must start with /ip4/ || /dns/
if !strings.HasPrefix(ma, "/ip4/") && !strings.HasPrefix(ma, "/dns/") {
errorMessage := fmt.Sprintf("Error generating the MultiAddress, must begin with /ip4/ || /dns/: [%nodeName]", ma)
errorMessage := fmt.Sprintf("Error generating the MultiAddress, must begin with /ip4/ || /dns/: [%s]", ma)
log.Error(errorMessage)
return errors.New(errorMessage)
}
Expand Down

0 comments on commit 1b5054a

Please sign in to comment.