class QuartzTorrent::BlockInfo

Information representing a single block (a part of a piece)

Attributes

blockIndex[RW]

Index of the block in units of the blockSize from the BlockState that created this object.

length[RW]

Length of the block in bytes.

offset[RW]

Offset (in bytes) within the piece where the block begins.

peers[RW]

A list of peers that have the piece this block belongs to. This block can be requested from these peers.

pieceIndex[RW]

The index of the piece that this block belongs to.

Public Class Methods

new(pieceIndex, offset, length, peers, blockIndex) click to toggle source
# File lib/quartz_torrent/blockstate.rb, line 8
def initialize(pieceIndex, offset, length, peers, blockIndex)
  @pieceIndex = pieceIndex
  @offset = offset
  @length = length
  @peers = peers
  @blockIndex = blockIndex
end

Public Instance Methods

getRequest() click to toggle source

Return a new Bittorrent Request message that requests this block.

# File lib/quartz_torrent/blockstate.rb, line 30
def getRequest
  m = Request.new
  m.pieceIndex = @pieceIndex
  m.blockOffset = @offset
  m.blockLength = @length
  m
end