Skip to content

Commit

Permalink
feat: tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Dec 1, 2023
1 parent 4d95e07 commit 601660c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ services:
ports:
- "${CRAWLER_PORT}:9020"
- "127.0.0.1:${CRAWLER_METRICS_PORT}:9080"
- "127.0.0.1:${CRAWLER_SSE_PORT}:9099"
- "${CRAWLER_SSE_PORT}:9099"
1 change: 1 addition & 0 deletions pkg/crawler/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func NewEthereumCrawler(mainCtx *cli.Context, conf config.EthereumCrawlerConfig)
default:
log.Error("untraceable gossipsub topic", top)
continue

}
topic := eth.ComposeTopic(conf.ForkDigest, top)
gs.JoinAndSubscribe(topic, msgHandler, conf.PersistMsgs)
Expand Down
13 changes: 8 additions & 5 deletions pkg/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ func (f *Forwarder) Start(ctx context.Context) error {
var err error

f.once.Do(func() {
f.startWorkers()

f.subscribeDownstream(ctx)

f.server.CreateStream(TopicEthereumAttestation)
f.server.CreateStream(TopicTimedEthereumAttestation)

err = f.startHTTPServer()
if err != nil {
return
Expand All @@ -83,19 +88,17 @@ func (f *Forwarder) startHTTPServer() error {
sseMux := http.NewServeMux()
sseMux.HandleFunc("/events", f.server.ServeHTTP)

log.WithField("address", f.ip).WithField("port", f.port).Info("Starting SSE server")

errCh := make(chan error, 1)
log.WithField("address", f.ip).WithField("port", f.port).Info("Starting SSE server!")

// Start the HTTP server
go func() {
err := http.ListenAndServe(fmt.Sprintf("%s:%d", f.ip, f.port), sseMux)
if err != nil {
errCh <- err
log.Fatal(err)
}
}()

return <-errCh
return nil
}

// subscribeDownstream subscribes to downstream "internal" events
Expand Down

0 comments on commit 601660c

Please sign in to comment.