anchor.diff:      chunk_map = ChunkMap ++ [Chunk],
       next_chunk_time = NextChunkTime,
       next_md_full = true}.
  -  
  + 
  +current_chunk_offset(#dbstate{file = File, chunk_map_offset = ChunkMapOffset} = _State) ->
  +  {ok, EOF} = file:position(File, eof),
  +  _ChunkOffset = EOF - ChunkMapOffset.
  +
  +write_chunk_offset(ChunkNumber, ChunkOffset, #dbstate{file = File, chunk_map_offset = ChunkMapOffset} = _State) ->
  +  ByteOffsetLen = ?OFFSETLEN div 8,
  +  ok = file:pwrite(File, ChunkMapOffset + ChunkNumber*ByteOffsetLen, <<ChunkOffset:?OFFSETLEN/integer>>).
  +
   
   append_full_md({md, Timestamp, Bid, Ask}, #dbstate{depth = Depth, file = File} = State) ->
     BidAsk = [setdepth(Bid, Depth), setdepth(Ask, Depth)],
  
positive.code: 
  read_chunk_map(#dbstate{} = State) ->
    ChunkMap = lists:map(fun({Number, Offset}) ->
          Timestamp = read_timestamp_at_offset(Offset, State),
          {Number, Timestamp, Offset}
      end, nonzero_chunks(State)),
    State#dbstate{chunk_map = ChunkMap}.
  
  
  nonzero_chunks(#dbstate{file = File, chunk_size = ChunkSize, chunk_map_offset = ChunkMapOffset}) ->
  
negative.code:   #dbstate{
      daystart = Daystart,
      chunk_size = ChunkSize,
      chunk_map = ChunkMap} = State,
  
    ChunkSizeMs = timer:?CHUNKUNITS(ChunkSize),
    ChunkNumber = (Timestamp - Daystart) div ChunkSizeMs,
  