Skip to content

Commit

Permalink
fix: miner loop resilience in the face of NewBlock errors
Browse files Browse the repository at this point in the history
Change-Id: Iae52ba844c2acd722eb314f71a310295c688faf3
  • Loading branch information
edmundnoble committed May 31, 2024
1 parent 668a579 commit 3d18d3d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Chainweb/Chainweb/MinerResources.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Control.Concurrent.Async
import Control.Concurrent.STM (atomically)
import Control.Concurrent.STM.TVar
import Control.Exception (evaluate)
import Control.Exception.Safe
import Control.Lens
import Control.Monad

Expand Down Expand Up @@ -189,6 +190,12 @@ withMiningCoordination logger conf cdb inner

-- Get a payload for the new block
maybeNewBlock <- _pactNewBlock pact cid miner True newParent
`onException` do
logFunctionText (chainLogger cid logger) Error
"creating new payload failed, resetting to old payload"
atomically $ modifyTVar' tpw (ourMiner .~ Just outdatedPayload)
approximateThreadDelay 1_000_000


case maybeNewBlock of
Nothing -> do
Expand Down

0 comments on commit 3d18d3d

Please sign in to comment.