-
Notifications
You must be signed in to change notification settings - Fork 179
/
notifier.go
26 lines (22 loc) · 950 Bytes
/
notifier.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package main
import (
"github.com/rs/zerolog"
"github.com/onflow/flow-go/consensus/hotstuff/notifications"
"github.com/onflow/flow-go/consensus/hotstuff/notifications/pubsub"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module"
metricsconsumer "github.com/onflow/flow-go/module/metrics/hotstuff"
)
// createLogger creates logger which reports chain ID on every log message.
func createLogger(log zerolog.Logger, chainID flow.ChainID) zerolog.Logger {
return log.With().Str("chain", chainID.String()).Logger()
}
// createNotifier creates a pubsub distributor and connects it to consensus consumers.
func createNotifier(log zerolog.Logger, metrics module.HotstuffMetrics) *pubsub.Distributor {
metricsConsumer := metricsconsumer.NewMetricsConsumer(metrics)
logsConsumer := notifications.NewLogConsumer(log)
dis := pubsub.NewDistributor()
dis.AddConsumer(metricsConsumer)
dis.AddConsumer(logsConsumer)
return dis
}