anchor.diff:          StatsPerTransfer#{TransferId => NewTransferStats}
       end, State#state.cached_stats, TransferIds),
   
  +    NewCachedBlocks = lists:foldl(fun(From, Acc) ->
  +        FromBlocks = maps:get(From, Acc, []),
  +        maps:put(From, [Block | FromBlocks], Acc)
  +    end, State#state.cached_blocks, AffectedFroms),
  +
       NewState = State#state{
           cached_stats = UpdatedStats,
  -        cached_blocks = [Block | State#state.cached_blocks]
  +        cached_blocks = NewCachedBlocks
       },
       set_caching_timers(NewState).
   
  
positive.code:     from_to_transfer_id = #{} :: #{from() => transfer:id() | undefined},
      transfer_id_to_from = #{} :: #{transfer:id() | undefined => from()},
      cached_stats = #{} :: #{undefined | transfer:id() => #{od_provider:id() => integer()}},
      cached_blocks = [] :: [block()],
      caching_stats_timer :: undefined | reference(),
      caching_blocks_timer :: undefined | reference(),
      caching_events_timer :: undefined | reference()
  
negative.code:     {ok, State}.
  
  terminate(_Reason, State) ->
      {_, State2} = flush_blocks(State, [], []),
      flush_stats(State2, true),
      flush_events(State2),
      % TODO VFS-4691 - should not terminate when flush failed
  