Commit 3a8c2ee4 authored by Michael de Hoog's avatar Michael de Hoog

Fix potential nil panics

parent 536340c4
...@@ -82,7 +82,7 @@ func (s *channelManager) TxFailed(id txID) { ...@@ -82,7 +82,7 @@ func (s *channelManager) TxFailed(id txID) {
} }
s.metr.RecordBatchTxFailed() s.metr.RecordBatchTxFailed()
if s.closed && len(s.confirmedTransactions) == 0 && len(s.pendingTransactions) == 0 { if s.closed && len(s.confirmedTransactions) == 0 && len(s.pendingTransactions) == 0 && s.pendingChannel != nil {
s.log.Info("Channel has no submitted transactions, clearing for shutdown", "chID", s.pendingChannel.ID()) s.log.Info("Channel has no submitted transactions, clearing for shutdown", "chID", s.pendingChannel.ID())
s.clearPendingChannel() s.clearPendingChannel()
} }
......
...@@ -212,13 +212,15 @@ func (l *BatchSubmitter) loadBlocksIntoState(ctx context.Context) { ...@@ -212,13 +212,15 @@ func (l *BatchSubmitter) loadBlocksIntoState(ctx context.Context) {
latestBlock = block latestBlock = block
} }
l2ref, err := derive.L2BlockToBlockRef(latestBlock, &l.Rollup.Genesis) if latestBlock != nil {
if err != nil { l2ref, err := derive.L2BlockToBlockRef(latestBlock, &l.Rollup.Genesis)
l.log.Warn("Invalid L2 block loaded into state", "err", err) if err != nil {
return l.log.Warn("Invalid L2 block loaded into state", "err", err)
} return
}
l.metr.RecordL2BlocksLoaded(l2ref) l.metr.RecordL2BlocksLoaded(l2ref)
}
} }
// loadBlockIntoState fetches & stores a single block into `state`. It returns the block it loaded. // loadBlockIntoState fetches & stores a single block into `state`. It returns the block it loaded.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment