Skip to content

Commit 552d1e6

Browse files
committed
expand comments about error handling and concurrency
1 parent 7098e40 commit 552d1e6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

consensus/hotstuff/voteaggregator/vote_aggregator.go

+5
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ func NewVoteAggregator(
109109

110110
// start vote collectors
111111
collectors.Start(signalerCtx)
112+
113+
// Handle the component lifecycle in a separate goroutine so we can capture any errors
114+
// thrown during initialization in the main goroutine.
112115
go func() {
113116
if err := util.WaitClosed(parentCtx, collectors.Ready()); err == nil {
114117
// only signal ready when collectors are ready, but always handle shutdown
@@ -122,6 +125,8 @@ func NewVoteAggregator(
122125

123126
// since we are breaking the connection between parentCtx and signalerCtx, we need to
124127
// explicitly rethrow any errors from signalerCtx to parentCtx, otherwise they are dropped.
128+
// Handle errors in the main worker goroutine to guarantee that they are rethrown to the parent
129+
// before the component is marked done.
125130
if err := util.WaitError(errCh, collectors.Done()); err != nil {
126131
parentCtx.Throw(err)
127132
}

0 commit comments

Comments
 (0)