node: collapse initialization internals (#7567)

This commit is contained in:
Sam Kleinman
2022-01-12 15:32:22 -05:00
committed by GitHub
parent 5c1399d803
commit e07c4cdcf2
9 changed files with 87 additions and 110 deletions
+12 -1
View File
@@ -10,6 +10,7 @@ import (
"time"
"github.com/tendermint/tendermint/internal/consensus"
"github.com/tendermint/tendermint/internal/eventbus"
"github.com/tendermint/tendermint/internal/p2p"
sm "github.com/tendermint/tendermint/internal/state"
"github.com/tendermint/tendermint/internal/store"
@@ -96,7 +97,8 @@ type Reactor struct {
// stopping the p2p Channel(s).
poolWG sync.WaitGroup
metrics *consensus.Metrics
metrics *consensus.Metrics
eventBus *eventbus.EventBus
syncStartTime time.Time
}
@@ -113,6 +115,7 @@ func NewReactor(
peerUpdates *p2p.PeerUpdates,
blockSync bool,
metrics *consensus.Metrics,
eventBus *eventbus.EventBus,
) (*Reactor, error) {
if state.LastBlockHeight != store.Height() {
@@ -146,6 +149,7 @@ func NewReactor(
blockSyncOutBridgeCh: make(chan p2p.Envelope),
peerUpdates: peerUpdates,
metrics: metrics,
eventBus: eventBus,
syncStartTime: time.Time{},
}
@@ -638,6 +642,13 @@ func (r *Reactor) GetRemainingSyncTime() time.Duration {
return time.Duration(int64(remain * float64(time.Second)))
}
func (r *Reactor) PublishStatus(ctx context.Context, event types.EventDataBlockSyncStatus) error {
if r.eventBus == nil {
return errors.New("event bus is not configured")
}
return r.eventBus.PublishEventBlockSyncStatus(ctx, event)
}
// atomicBool is an atomic Boolean, safe for concurrent use by multiple
// goroutines.
type atomicBool int32
+3 -1
View File
@@ -181,7 +181,9 @@ func (rts *reactorTestSuite) addNode(
chCreator,
rts.peerUpdates[nodeID],
rts.blockSync,
consensus.NopMetrics())
consensus.NopMetrics(),
nil, // eventbus, can be nil
)
require.NoError(t, err)
require.NoError(t, rts.reactors[nodeID].Start(ctx))