Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor node config #327

Merged
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
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
Loading