Sealer
Overview
Run Method
func (s *Sealer) run(ctx context.Context) {
sub := s.blockchain.SubscribeEvents()
eventCh := sub.GetEventCh()
for {
if s.config.DevMode {
// In dev-mode we wait for new transactions to seal blocks
select {
case <-s.wakeCh:
case <-ctx.Done():
return
}
}
// start sealing
subCtx, cancel := context.WithCancel(ctx)
done := s.sealAsync(subCtx)
// wait for the sealing to be done
select {
case <-done:
// the sealing process has finished
case <-ctx.Done():
// the sealing routine has been canceled
case <-eventCh:
// there is a new head, reset sealer
}
// cancel the sealing process context
cancel()
if ctx.Err() != nil {
return
}
}
}Last updated