Skip to content

Commit

Permalink
Use the new MessagesToSign API
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Sztandera <[email protected]>
  • Loading branch information
Kubuxu committed Jul 12, 2024
1 parent 5f95362 commit 5ceba75
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions chain/lf3/f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,9 @@ func (fff *F3) runSigningLoop(ctx context.Context) {
}

leaseMngr := new(leaseManager)
// create channel for some buffer so we don't get dropped under high load
msgCh := make(chan *gpbft.MessageBuilder, 4)
// SubscribeForMessagesToSign will close the channel if it fills up
// so using the closer is not necessary, we can just drop it on the floor
_ = fff.inner.SubscribeForMessagesToSign(msgCh)
// MessagesToSign is never closed
msgCh := fff.inner.MessagesToSign()

loop:
for ctx.Err() == nil {
select {
case <-ctx.Done():
Expand All @@ -133,14 +129,7 @@ loop:
// resultCh has only one user and is buffered
l.resultCh <- leaseMngr.UpsertDefensive(l.minerID, l.newExpiration, l.oldExpiration)
close(l.resultCh)
case mb, ok := <-msgCh:
if !ok {
// we got dropped, resubscribe
msgCh = make(chan *gpbft.MessageBuilder, cap(msgCh))
_ = fff.inner.SubscribeForMessagesToSign(msgCh)
continue loop
}

case mb := <-msgCh:
for _, minerID := range leaseMngr.Active() {
err := participateOnce(ctx, mb, minerID)
if err != nil {
Expand Down

0 comments on commit 5ceba75

Please sign in to comment.