Skip to content

Commit

Permalink
feat: refactor node config
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura committed Mar 4, 2024
1 parent c3d3969 commit b915689
Show file tree
Hide file tree
Showing 14 changed files with 671 additions and 342 deletions.
18 changes: 9 additions & 9 deletions cmd/cartesi-rollups-node/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,37 @@ func newHttpServiceHandler(nodeConfig config.NodeConfig) http.Handler {
handler.Handle("/healthz", http.HandlerFunc(healthcheckHandler))

graphqlProxy, err := newReverseProxy(
nodeConfig.CartesiHttpAddress,
getPort(nodeConfig.CartesiHttpPort, portOffsetGraphQLServer),
nodeConfig.CartesiHttpAddress(),
getPort(nodeConfig.CartesiHttpPort(), portOffsetGraphQLServer),
)
if err != nil {
config.ErrorLogger.Fatal(err)
}
handler.Handle("/graphql", graphqlProxy)

dispatcherProxy, err := newReverseProxy(
nodeConfig.CartesiHttpAddress,
getPort(nodeConfig.CartesiHttpPort, portOffsetDispatcher),
nodeConfig.CartesiHttpAddress(),
getPort(nodeConfig.CartesiHttpPort(), portOffsetDispatcher),
)
if err != nil {
config.ErrorLogger.Fatal(err)
}
handler.Handle("/metrics", dispatcherProxy)

inspectProxy, err := newReverseProxy(
nodeConfig.CartesiHttpAddress,
getPort(nodeConfig.CartesiHttpPort, portOffsetInspectServer),
nodeConfig.CartesiHttpAddress(),
getPort(nodeConfig.CartesiHttpPort(), portOffsetInspectServer),
)
if err != nil {
config.ErrorLogger.Fatal(err)
}
handler.Handle("/inspect", inspectProxy)
handler.Handle("/inspect/", inspectProxy)

if nodeConfig.CartesiFeatureHostMode {
if nodeConfig.CartesiFeatureHostMode() {
hostProxy, err := newReverseProxy(
nodeConfig.CartesiHttpAddress,
getPort(nodeConfig.CartesiHttpPort, portOffsetHostRunnerRollups),
nodeConfig.CartesiHttpAddress(),
getPort(nodeConfig.CartesiHttpPort(), portOffsetHostRunnerRollups),
)
if err != nil {
config.ErrorLogger.Fatal(err)
Expand Down
8 changes: 5 additions & 3 deletions cmd/cartesi-rollups-node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ func main() {

nodeConfig := config.NewNodeConfigFromEnv()

sunodoValidatorEnabled := nodeConfig.CartesiExperimentalSunodoValidatorEnabled
nodeConfig.Validate()

sunodoValidatorEnabled := nodeConfig.CartesiExperimentalSunodoValidatorEnabled()
if !sunodoValidatorEnabled {
// add Redis first
s = append(s, newRedis(nodeConfig))
Expand All @@ -34,14 +36,14 @@ func main() {
s = append(s, newStateServer(nodeConfig))

// start either the server manager or host runner
if nodeConfig.CartesiFeatureHostMode {
if nodeConfig.CartesiFeatureHostMode() {
s = append(s, newHostRunner(nodeConfig))
} else {
s = append(s, newServerManager(nodeConfig))
}

// enable claimer if reader mode and sunodo validator mode are disabled
if !nodeConfig.CartesiFeatureDisableClaimer && !sunodoValidatorEnabled {
if !nodeConfig.CartesiFeatureDisableClaimer() && !sunodoValidatorEnabled {
s = append(s, newAuthorityClaimer(nodeConfig))
}

Expand Down
Loading

0 comments on commit b915689

Please sign in to comment.