# File lib/rubytorrent/package.rb, line 267
  def initialize(index, sha1, start, length, files, validity_assumption=nil)
    @index = index
    @sha1 = sha1
    @start = start
    @length = length
    @files = files # array of [file pointer, mutex, file length]
    @valid = nil

    ## calculate where we start and end in terms of the file pointers.
    @start_index = 0
    sum = 0
    while(sum + @files[@start_index][2] <= @start)
      sum += @files[@start_index][2]
      @start_index += 1
    end
    ## now sum + @files[@start_index][2] > start, and sum <= start
    @start_offset = @start - sum

    ## sections of the data we have
    @have = Covering.new(AwesomeRange.new(0 ... @length)).complete!
    @valid = validity_assumption
    @have.empty! unless valid?

    ## sections of the data someone has laid claim to but hasn't yet
    ## provided. a super-set of @have.
    @claimed = Covering.new(AwesomeRange.new(0 ... @length))

    ## protects @claimed, @have
    @state_m = Mutex.new
  end