anchor.diff:  %% @doc Maybe send a message to one of the
   %%      gen_servers to write another block,
   %%      and then return the updated func inputs
  --spec maybe_write_block(term(), term(), term()) -> {term(), term(), term()}.
  -maybe_write_block(BufferQueue, FreeWriters, UnackedWrites) ->
  -    {BufferQueue, FreeWriters, UnackedWrites}.
  +-spec maybe_write_blocks(term()) -> term().
  +maybe_write_blocks(State=#state{buffer_queue=[]}) ->
  +        State;
  +maybe_write_blocks(State=#state{free_writers=[]}) ->
  +        State;
  +maybe_write_blocks(State=#state{buffer_queue=[ToWrite, RestBuffer],
  +                                free_writers=FreeWriters,
  +                                unacked_writes=UnackedWrites,
  +                                bucket=Bucket,
  +                                key=Key,
  +                                manifest=Manifest,
  +                                next_block_id=NextBlockID}) ->
  +
  +    UUID = Manifest#lfs_manifest_v2.uuid,
  +    WriterPid = hd(ordsets:to_list(FreeWriters)),
  +    NewFreeWriters = ordsets:del_element(WriterPid, FreeWriters),
  +    NewUnackedWrites = ordsets:add_element(NextBlockID, UnackedWrites),
  +
  +    riak_moss_block_server:put_block(WriterPid, Bucket, Key, UUID, NextBlockID, ToWrite),
  +
  +    maybe_write_blocks(State#state{buffer_queue=RestBuffer,
  +                                   free_writers=NewFreeWriters,
  +                                   unacked_writes=NewUnackedWrites,
  +                                   next_block_id=(NextBlockID + 1)}).
   
   -spec state_from_block_written(non_neg_integer(), pid(), term()) -> term().
  -state_from_block_written(BlockID, WriterPid,
  -                                State=#state{unacked_writes=UnackedWrites,
  -                                             free_writers=FreeWriters,
  -                                             buffer_queue=BufferQueue}) ->
  -    NewUnackedSet = ordsets:del_element(BlockID, UnackedWrites),
  +state_from_block_written(BlockID, WriterPid, State=#state{unacked_writes=UnackedWrites,
  +                                                          free_writers=FreeWriters}) ->
  +    NewUnackedWrites = ordsets:del_element(BlockID, UnackedWrites),
       NewFreeWriters = ordsets:add_element(WriterPid, FreeWriters),
  -    %% 3. Maybe write another block
  -    {NewBufferQueue, NewFreeWriters2, NewUnackedSet2} =
  -    maybe_write_block(BufferQueue, NewFreeWriters, NewUnackedSet),
  -    State#state{unacked_writes=NewUnackedSet2,
  -                free_writers=NewFreeWriters2,
  -                buffer_queue=NewBufferQueue}.
  +    maybe_write_blocks(State#state{unacked_writes=NewUnackedWrites,
  +                                   free_writers=NewFreeWriters}).
   
   %% @private
   %% @doc Start a number
  
positive.code:                 remainder_data :: binary(),
                  free_writers :: ordsets:new(),
                  unacked_writes=ordsets:new(),
                  all_writer_pids :: list(pid())}).
  
  %%%===================================================================
  
negative.code:                                                           buffer_queue=BufferQueue,
                                                            remainder_data=RemainderData,
                                                            num_bytes_received=PreviousBytesReceived,
                                                            content_length=ContentLength}) ->
  
      NewRemainderData = combine_new_and_remainder_data(NewData, RemainderData),
      UpdatedBytesReceived = PreviousBytesReceived + size(NewData),
  
      {NewBufferQueue, NewRemainderData2} =
      data_blocks(NewRemainderData, ContentLength, UpdatedBytesReceived, BufferQueue),
  
      NewStateData = maybe_write_blocks(State#state{buffer_queue=NewBufferQueue,
                                                    remainder_data=NewRemainderData2,
                                                    num_bytes_received=UpdatedBytesReceived}),
  
      {noreply, full, NewStateData#state{reply_pid=From}}.
  
  handle_receiving_last_chunk(NewData, State=#state{buffer_queue=BufferQueue,
                                                    remainder_data=RemainderData,
                                                    num_bytes_received=PreviousBytesReceived,
                                                    content_length=ContentLength}) ->
  
      NewRemainderData = combine_new_and_remainder_data(NewData, RemainderData),
      UpdatedBytesReceived = PreviousBytesReceived + size(NewData),
  
      {NewBufferQueue, NewRemainderData2} =
      data_blocks(NewRemainderData, ContentLength, UpdatedBytesReceived, BufferQueue),
  
      NewStateData = maybe_write_blocks(State#state{buffer_queue=NewBufferQueue,
                                                    remainder_data=NewRemainderData2,
                                                    num_bytes_received=UpdatedBytesReceived}),
  
      Reply = ok,
      {reply, Reply, all_received, NewStateData}.
  