anchor.diff:      State2 = State1#state{ candidate = Candidate
                            , candidate_state = CandidateState },
       {noreply, maybe_start_worker_txs(State2)};
  -handle_cast({worker_done, Result}, State = #state{ worker = {Pid, _}}) ->
  +handle_cast({worker_done, Pid, {failed, Reason}}, State = #state{ worker = {Pid, _}}) ->
       State1 = finish_worker(State),
  -    lager:debug("Candidate worker ~p done ~p", [Pid, Result]),
  +    lager:debug("Candidate worker ~p failed ~p", [Pid, Reason]),
       {noreply, State1};
  +handle_cast({worker_done, OldPid, Result}, State) ->
  +    lager:debug("Ignored stale worker reply ~p (from worker ~p)", [Result, OldPid]),
  +    {noreply, State};
   handle_cast(Msg, State) ->
       lager:info("Unexpected message ~p", [Msg]),
       {noreply, State}.
  
positive.code: %% Generate block candidate
  create_block_candidate(BlockOrBlockHash) ->
      case aec_block_micro_candidate:create(BlockOrBlockHash) of
          {ok, NewBlock, BlockInfo} ->
              gen_server:cast(?MODULE, {new_candidate, NewBlock, BlockInfo});
          {error, Reason} ->
              failed_attempt(Reason)
      end,
  
negative.code: 
  update_block_candidate(Block, BlockInfo, Txs) ->
      case aec_block_micro_candidate:update(Block, Txs, BlockInfo) of
          {ok, NewBlock, NewBlockInfo} ->
              new_candidate(NewBlock, NewBlockInfo);
          {error, Reason} ->
              failed_attempt(Reason)
      end.
  
  failed_attempt(Reason) ->
      gen_server:cast(?MODULE, {worker_done, self(), {failed, Reason}}).
  
  new_candidate(NewBlock, NewBlockInfo) ->
      gen_server:cast(?MODULE, {worker_done, self(), {candidate, NewBlock, NewBlockInfo}}).
  
  publish_candidate(_Block) ->
      aec_events:publish(candidate_block, new_candidate).
  