Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion txnprovider/shutter/decrypted_txns_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func NewDecryptedTxnsPool() *DecryptedTxnsPool {
}

func (p *DecryptedTxnsPool) Wait(ctx context.Context, mark DecryptionMark) error {
var found bool
done := make(chan struct{})
go func() {
defer close(done)
Expand All @@ -59,17 +60,21 @@ func (p *DecryptedTxnsPool) Wait(ctx context.Context, mark DecryptionMark) error
for _, ok := p.decryptedTxns[mark]; !ok && ctx.Err() == nil; _, ok = p.decryptedTxns[mark] {
p.decryptionCond.Wait()
}
_, found = p.decryptedTxns[mark]
}()

select {
case <-ctx.Done():
// note the below will wake up all waiters prematurely, but thanks to the for loop condition
// in the waiting goroutine the ones that still need to wait will go back to sleep
p.decryptionCond.Broadcast()
<-done
Comment on lines 67 to +71
case <-done:
// no-op
}

if found {
return nil
}
return ctx.Err()
}

Expand Down
Loading