BitfieldMan::getMissingIndexes family functions now takes
unsigned char* bitfield instead of stl container for efficiency.
PieceSelector::select now takes this
bitfield. RarestPieceSelector::select now also performs
efficiently for this change. bitfield namespace is introduced
and it has several helper functions to handle basic bitfield
operations such as test, count set bits, etc.
* src/BitfieldMan.cc
* src/BitfieldMan.h
* src/DefaultBtRequestFactory.cc
* src/DefaultPieceStorage.cc
* src/DefaultPieceStorage.h
* src/LongestSequencePieceSelector.cc
* src/LongestSequencePieceSelector.h
* src/Makefile.am
* src/Piece.cc
* src/Piece.h
* src/PieceSelector.h
* src/RarestPieceSelector.cc
* src/RarestPieceSelector.h
* src/Util.cc
* src/Util.h
* src/bitfield.h
* test/BitfieldManTest.cc
* test/LongestSequencePieceSelectorTest.cc
* test/Makefile.am
* test/RarestPieceSelectorTest.cc
* test/UtilTest.cc
* test/bitfieldTest.cc
Filled up pieces based on the number of missing blocks, rather
than
simplay the number of piece * block length.
* src/BtRequestFactory.h
* src/DefaultBtInteractive.cc
* src/DefaultBtInteractive.h
* src/DefaultBtRequestFactory.cc
* src/DefaultBtRequestFactory.h
* src/Piece.cc
* src/Piece.h
* test/BitfieldManTest.cc
* test/DefaultBtRequestFactoryTest.cc
* test/MockBtRequestFactory.h
Calculate piece hash when data is arrived if the data is arrived
in
order. This removes additional read operation for hash
calculation.
If the data is arrived in out of order, the hash is calucated
when the
piece is completed. This is the same behavior as the old
implementation.
* src/BtPieceMessage.cc
* src/DefaultBtProgressInfoFile.cc
* src/DefaultPieceStorage.cc
* src/DownloadCommand.cc
* src/DownloadCommand.h
* src/DownloadEngine.cc
* src/GrowSegment.cc
* src/GrowSegment.h
* src/Piece.cc
* src/Piece.h
* src/PiecedSegment.cc
* src/PiecedSegment.h
* src/Segment.h
* test/PieceTest.cc
Added Piece::getFirstMissingBlockIndexWithoutLock() and it is
called
from PiecedSegment's ctor.
Previously Piece::getAllMissingBlockIndexes() is called from
PiecedSegment() but it is rather expensive since only first
element is
used.
* src/PiecedSegment.cc
* src/Piece.{h, cc}
* src/Piece.{h, cc}: Added SubPiece infrastructure to track down
the data smaller than block length.
A block length can be specified by constructor's argument.
* src/DefaultPieceStorage.{h, cc} (getMissingPiece):
Get a missing piece in the range of given FileEntry. This
function is
not used in the program yet.
* src/Util.h: Added some macros.
Implemented BitTorrent/http/ftp integrated download.
I've rewritten lots of files and now some headers have forward
class declarations to reduce compile time.
The implementation is extremely alpha stage, I recommend to use this
for testing purpose only.
Rewritten a portion of bittorrent implementation:
* src/BtMessageValidator.h: New class.
* src/BtBitfieldMessageValidator.h: New class.
* src/BtHandshakeMessageValidator.h: New class.
* src/BtRequestMessageValidator.h: New class.
* src/BtSuggestPieceMessageValidator.h: New class.
* src/BtAllowedFastMessageValidator.h: New class.
* src/BtRejectMessageValidator.h: New class.
* src/BtCancelMessageValidator.h: New class.
* src/BtPieceMessageValidator.h: New class.
* src/BtHaveMessageValidator.h: New class.
* src/BtEventListener.h: New class.
* src/AbstractBtEventListener.h: New class.
* src/BtEvent.h: New class.
* src/BtChokingEvent.h: New class.
* src/BtChokedEvent.h: New class.
* src/BtCancelSendingPieceEvent.h: New class.
* src/BtAbortOutstandingRequestEvent.h: New class.
* src/Randomizer.h: New class.
* src/SimpleRandomizer.h: New class.
* src/BtMessage.h: New class.
* src/AbstractBtMessage.h: New class.
* src/SimpleBtMessage.h: New class.
* src/BtHaveMessage.h: New class.
* src/BtInterestedMessage.h: New class.
* src/BtAllowedFastMessage.h: New class.
* src/BtUnchokeMessage.h: New class.
* src/BtCancelMessage.h: New class.
* src/BtNotInterestedMessage.h: New class.
* src/BtChokeMessage.h: New class.
* src/BtHaveNoneMessage.h: New class.
* src/BtHandshakeMessage.h: New class.
* src/BtSuggestPieceMessage.h: New class.
* src/BtHaveMessage.h: New class.
* src/BtPieceMessage.h: New class.
* src/BtHaveAllMessage.h: New class.
* src/BtKeepAliveMessage.h: New class.
* src/BtPortMessage.h: New class.
* src/BtRejectMessage.h: New class.
* src/BtBitfieldMessage.h: New class.
* src/BtRequestMessage.h: New class.
* src/DefaultBtRequestFactory.h: New class.
* src/DefaultBtMessageReceiver.h: New class.
* src/BtInteractive.h: New class.
* src/BtMessageDispatcher.h: New class.
* src/DefaultBtMessageDispatcher.h: New class.
* src/DefaultBtInteractive.h: New class.
* src/BitfieldManFactory.h: New class.
* src/HandleRegistry.h: New class.
* src/BtMessageFactory.h: New class.
* src/BtMessageReceiver.h: New class.
* src/DefaultBtMessageFactory.h: New class.
* src/PeerObject.h: New class.
* src/BtRequestFactory.h: New class.
To divide TorrentMan into 6 classes: BtContext, BtRuntime,
PeerStorage, PieceStorage, BtAnnounce and BtProgressInfoFile
* src/TrackerWatcherComand.h: Made subclass of
BtContextAwareCommand.
* src/SeedCheckCommand.cc: Use pieceStorage, btRuntime
* src/PeerAbstractCommand.h: Made subclass of
BtContextAwareCommand.
* src/PeerAbstractCommand.cc: Use btRuntime.
* src/BtContextAwareCommand.h: New class.
* src/FileEntry.h: Added accessor methods for following
variables.
(path): Made private.
(length): Made private.
(offset): Made private.
(extracted): Made private.
(requested): Made private.
(FileEntries): New definition.
(FileEntryHandle): New definition.
* src/FileEntry.cc: New file.
* src/HaveEraseCommand.h: Made subclass of
BtContextAwareCommand.
* src/HaveEraseCommand.cc: Use btRuntime, pieceStorage.
* src/PeerChokeCommand.h: Made subclass of
BtContextAwareCommand.
* src/PeerChokeCommand.cc: Use btRuntime, peerStorage,
pieceStorage.
* src/PieceStorage.h: New file.
* src/PeerInteractionCommand.h: Use btContext.
* src/PeerInteractionCommand.cc: Use pieceStorage, peerStorage,
btRuntime.
* src/DefaultBtProgressInfoFile.h: New file.
* src/DefaultBtProgressInfoFile.cc: New file.
* src/File.cc
(Util.h): New include.
(mkdirs): New function.
* src/MultiDiskAdaptor.h
(mkdir): New function.
* src/PeerListProcessor.h
(Peers): Removed.
* src/PeerInteraction.h
(torrentMan): Removed.
(btContext): New variable.
(peerStorage): New variable.
(pieceStorage): New variable.
(btAnnounce): New variable.
(getTorrentMan): Removed.
(getBtContext): New function.
* src/PeerInteraction.cc: Use btContext, peerStorage,
pieceStorage,
btAnnounce.
* src/HandshakeMessage.h
(TorrentMan.h): Removed.
* src/HandshakeMessage.cc: Use btContext.
* src/DefaultBtAnnounce.cc: New file.
* src/MultiDiskWriter.cc: Use the accessor methods of FileEntry.
* src/DefaultPieceStorage.cc: New file.
* src/DefaultBtContext.h: New file.
* src/TorrentRequestInfo.cc: Use btContext, pieceStorage.
Use the accessor methods of FileEntry.
* src/CookieBox.cc: Updated to use Util::slice().
* src/PieceMessage.cc: Use btContext, pieceStorage.
* src/common.h (SharedHandle.h): New include.
* src/PeerMessage.cc (PeerMessage): Added btContext,
peerStorage,
pieceStorage.
* src/TorrentAutoSaveCommand.h: Made subclass of
BtContextAwareCommand.
* src/DiskAdaptor.h
(topDir): Removed.
(getFileEntryFromPath): Changed the return type to
FileEntryHandle.
(setTopDir): Removed.
(getTopDir): Removed.
* src/BtContext.h: New file.
* src/DefaultPeerStorage.h: New file.
* src/PieceMessage.h (TorrentMan.h): Removed.
* src/RequestMessage.h (TorrentMan.h): Removed.
* src/TorrentDownloadEngine.h
(uploadLength): New variable.
(btContext): New variable.
(btRuntime): New variable.
(pieceStorage): New variable.
(peerStorage): New variable.
(btAnnounce): New variable.
(btProgressInfoFile): New variable.
(torrentMan): Removed.
(setBtContext): New function.
* src/TorrentDownloadEngine.cc: Use BtContext, BtRuntime,
pieceStorage,
peerStorage, btAnnounce, btProgressInfoFile.
* src/Piece.h
(toString): New function.
(Pieces): New type definition.
* src/Peer.h
(active): New variable.
(Peer): Added active.
(activate): Set active to true.
(deactivate): Set active to false.
(isActive): New function.
(Peers): New type definition.
* src/DirectDiskAdaptor.cc
(getFilePath): Use the accessor methods of FileEntry.
* src/TorrentConsoleDownloadEngine.h
(afterEachIteration): New function.
* src/TorrentConsoleDownloadEngine.cc
(haltRequested): New variable.
(sendStatistics): Use pieceStorage, btRuntime.
(afterEachIteration): New function.
* src/AnnounceList: AnnounceTier->AnnounceTierHandle.
* src/Directry.h
(Directory): New function.
(DirectoryHandle): New type definition.
* src/BtProgressInfoFile.h: New file.
* src/RequestMessage.cc: Use pieceStorage.
* src/BtRuntime.h: New file.
* src/DefaultBtContext.cc: New file.
* src/BitfieldMan.h
(getCompletedLength): New function(private).
(getCompletedLength): New function.
(getFilteredCompletedLength): New function.
* src/BitfieldMan.h
(getCompletedLength): New function(private).
(getCompletedLength): New function.
(getFilteredCompletedLength): New function.
* src/MultiDiskAdaptor.cc
(mkdir): New function.
(openFile): Call mkdir().
(initAndOpenFile): Call mkdir().
* src/CancelMessage.h
(TorrentMan.h): Removed.
* src/RejectMessage.h
(TorrentMan.h): Removed.
* src/DownloadEngineFactory.cc
(DefaultPieceStorage.h): New include.
(DefaultPeerStorage.h): New include.
(DefaultBtAnnounce.h): New include.
(DefaultBtProgressInfoFile.h): New include.
(newTorrentConsoleEngine): Rewritten.
* src/ShareRatioSeedCriteria.h
(torrentMan): Removed.
(btContext): New variable.
(peerStorage): New variable.
(btRuntime): New variable.
(evaluate): Use btContext, btRuntime, peerStorage.
* src/AnnounceTier.h: New file.
* src/BtAnnounce.h: New file.
* src/BtRegistry.h: New file.
* src/PeerInitiateConnectionCommand.h: Added btContext.
* src/PeerConnection.h (TorrentMan.h): Removed.
* src/PeerMessageFactory.cc: Use btContext, pieceStorage.
* src/Util.h
(slice): Added an argument.
* src/Util.cc
(slice): Added an argument to control whether trim is made or
not.
* src/PeerStorage.h: New file.
* src/BtRegistry.cc: New file.
* src/TrackerUpdateCommand.h: Made subclass of
BtContextAwareCommand.
* src/CopyDiskAdaptor.cc: Use the accessor methods of FileEntry.
* src/MultiDiskWriter.h: FileEntry -> FileEntryHandle
* src/PeerListenCommand.cc: Use btRuntime, peerStorage,
btContext.
* src/TorrentRequestInfo.h
(e): Removed.
(showFileEntry): Added an argument.
(getDownloadEngine): Return 0.
* src/DefaultBtAnnounce.h: New file.
* src/TorrentAutoSaveCommand.cc: Use btRuntime,
btProgressInfoFile.
* src/TrackerWatcherComand.cc: Use btRuntime, btAnnounce,
* src/PeerMessageFactory.h
(btContext): New variable.
(pieceStorage): New variable.
* src/TrackerUpdateCommand.cc: Use btRuntime, peerStorage,
btContext,
btAnnounce.
* src/DiskAdaptor.cc
(DiskAdaptor): Removed topDir.
(~DiskAdaptor): Removed topDir.
* src/PeerListenCommand.h: Made subclass of
BtContextAwareCommand.
* src/SeedCheckCommand.h: Made subclass of
BtContextAwareCommand.
* src/File.h (mkdirs): New function.
* src/DefaultPeerStorage): New file.
* src/DownloadEngineFactory.h
(newTorrentConsoleEngine): Use btContext.
* src/BtContextAwareCommand.cc: New file.
* src/PeerInitiateConnectionCommand.cc: Use btRuntime,
peerStorage.
* src/PeerMessage.h
(btContext): New variable.
(peerStorage): New variable.
(pieceStorage): New variable.
(setBtContext): New function.
* src/Directry.cc
(Directory): New function.
(createDir): Do nothing if name.size() == 0.
* src/AnnounceList.h
(AnnounceTier): Removed.
(AnnounceTiers): Removed.
* src/DefaultPieceStorage.h: New file.
* src/Piece.cc (toString): New function.
To fix typo:
* src/main.cc (showVersion): Fixed typo.
To fix compile warning:
* src/DelegatingPeerListProcessor.cc
(canHandle): Added "return false".
* src/PeerMessage.h
(Piece.h): Included.
(SharedHandle.h): Included.
(invalidate): New variable.
(uploading): New variable.
(isInvalidate): New function.
(isUploading): New function.
(onPush): New function.
(onChoked): New function.
(onCanceled): New function.
(onAbortPiece): New function.
(PeerMessageHandle): New type definition.
* src/PeerMessage.cc
(PeerMessage): Added the initialization for invalidate and
uploading.
* src/CancelMessage.h
(CancelMessage): Rewritten.
* src/RejectMessage.h
(RejectMessage): Rewritten.
* src/Metalinker.h
(operator=): Defined.
* src/MetaEntry.h
(operator=): Defined.
* src/MetalinkResource.h
(operator=): Defined.
* src/AllowedFastMessage.h
(AllowedFastMessage): Rewritten.
* src/HandshakeMessage.h
(HandshakeMessage): New function(overload).
* src/HandshakeMessage.cc
(HandshakeMessage): Rewritten.
(init): New function.
* src/HaveMessage.h
(HaveMessage): Rewritten.
* src/Time.h
(operator=): Defined the function body here.
* src/Time.cc
(operator=): Removed.
* src/SocketCore.h
(operator==): Defined here.
(operator!=): Defined here.
(operator<): Defined here.
* src/SocketCore.cc
(operator==): Removed.
(operator<): Removed.
* src/BitfieldMan.h
(operator=): Defined the function body here.
* src/BitfieldMan.cc
(operator=): Removed.
* src/TorrentMan.h
(deleteErrorPeer): Removed.
(deleteUnusedPeer); New function.
* src/TorrentMan.cc
(addPeer): Call deleteUnusedPeer.
(deleteErrorPeer): Removed.
(deleteUnusedPeer): New function.
* src/PeerAbstractCommand.h
(setNoCheck): New function.
(noCheck): New variable.
* src/PeerAbstractCommand.cc
(PeerAbstractCommand): Added the initialization of noCheck.
(execute): Added a check for noCheck.
(setNoCheck): New function.
* src/Util.h
(stdio.h): Included.
* src/Util.cc
(unistd.h): Included.
* src/DefaultDiskWriter.cc
(unistd.h): Included.
* src/Peer.h
(operator==): Defined the function body here.
(operator!=): Defined the function body here.
* src/Peer.cc
(operator==): Removed.
(operator!=): Removed.
* src/Piece.h
(Piece): Defined the function body here(copy constructor).
(operator=): Defined the function body here.
(operator==): Defined the function body here.
* src/Piece.cc
(Piece): Removed(copy constructor).
(operator=): Removed.
(operator==): Removed.
* src/PeerMessageUtil.h
(ChokeMessage.h): Removed.
(UnchokeMessage.h): Removed.
(InterestedMessage.h): Removed.
(NotInterestedMessage.h): Removed.
(HaveMessage.h): Removed.
(BitfieldMessage.h): Removed.
(RequestMessage.h): Removed.
(CancelMessage.h): Removed.
(PieceMessage.h): Removed.
(HandshakeMessage.h): Removed.
(KeepAliveMessage.h): Removed.
(PortMessage.h): Removed.
(HaveAllMessage.h): Removed.
(HaveNoneMessage.h): Removed.
(PeerConnection.h): Removed.
(HandshakeMessage.h): Included.
* src/BitfieldMessage.h
(init): New function.
(BitfieldMessage): Rewritten.
(BitfieldMessage): New function(overload).
* src/RequestSlot.h
(operator=): Defined the function body here.
(operator==): Defined the function body here.
* src/RequestSlot.cc
(operator=): Removed.
(operator==): Removed.
To remove the dependency on the PeerMessage subclass from
PeerInteraction:
* src/PeerMessageFactory.h: New class.
* src/PeerMessageFactory.cc: New class.
* src/SimplePeerMessage.cc
(send): If invalidate is true then do nothing.
* src/PeerInteractionCommand.cc
(HandshakeMessage.h): Included.
(KeepAliveMessage.h): Included.
(ChokeMessage.h): Included.
(UnchokeMessage.h): Included.
(HaveMessage.h): Included.
(executeInternal): Call setNoCheck().
Removed setWriteCheckSocket(socket).
* src/PeerInteraction.h
(ChokeMessage.h): Removed.
(UnchokeMessage.h): Removed.
(InterestedMessage.h): Removed.
(NotInterestedMessage.h): Removed.
(HaveMessage.h): Removed.
(BitfieldMessage.h): Removed.
(RequestMessage.h): Removed.
(CancelMessage.h): Removed.
(PieceMessage.h): Removed.
(HandshakeMessage.h): Removed.
(KeepAliveMessage.h): Removed.
(PortMessage.h): Removed.
(HaveAllMessage.h): Removed.
(HaveNoneMessage.h): Removed.
(RejectMessage.h): Removed.
(AllowedFastMessage.h): Removed.
(SuggestPieceMessage.h): Removed.
(PeerMessageFactory.h): Included.
(PeerMessageHandle): Removed typedef of PeerMessageHandle.
(HandshakeMessageHandle): Removed typedef of
HandshakeMessageHandle.
(PeerMessageFactory): New variable.
(createPeerMessage): Removed.
(createHandshakeMessage): Removed.
(setPeerMessageCommonProperty): Removed.
(addRequestSlot): New function.
(receiveHandshake): Changed the return value type to
PeerMessageHandle.
(getPeerMessageFactory): New function.
(createRequestMessage): Removed.
(createCancelMessage): Removed.
(createPieceMessage): Removed.
(createHaveMessage): Removed.
(createChokeMessage): Removed.
(createUnchokeMessage): Removed.
(createInterestedMessage): Removed.
(createNotInterestedMessage): Removed.
(createBitfieldMessage): Removed.
(createKeepAliveMessage): Removed.
(createHaveAllMessage): Removed.
(createHaveNoneMessage): Removed.
(createRejectMessage): Removed.
(createAllowedFastMessage): Removed.
* src/PeerInteraction.cc
(PeerInteraction): Allocate PeerMessageFactory here.
(~PeerInteraction): Deallocate PeerMessageFactory here.
(sendMessages): Use msg->isUploading() instead of msg->getId()
==
PieceMessage::ID.
(addMessage): Simplified by using PeerMessage::onPush().
(addRequestSlot): New function.
(rejectAllPieceMessageInQueue): Simplified by using
PeerMessage::onChoked().
(rejectPieceMessageInQueue): Simplified by using
PeerMessage::onCanceled().
(abortPiece): Simplified by using PeerMessage::abortPiece().
(receiveHandshake): Changed the return value type to
PeerMessageHandle.
(createHandshakeMessage): Removed.
(createPeerMessage): Removed.
(sendHandshake): Call
PeerMessageFactory::createHandshakeMessage().
(setPeerMessageCommonProperty): Removed.
(createRequestMessage): Removed.
(createCancelMessage): Removed.
(createPieceMessage): Removed.
(createHaveMessage): Removed.
(createChokeMessage): Removed.
(createUnchokeMessage): Removed.
(createInterestedMessage): Removed.
(createNotInterestedMessage): Removed.
(createBitfieldMessage): Removed.
(createKeepAliveMessage): Removed.
(createHaveAllMessage): Removed.
(createHaveNoneMessage): Removed.
(createRejectMessage): Removed.
(createAllowedFastMessage): Removed.
* src/PieceMessage.h
(createRejectMessage): New function.
(PieceMessage): Rewritten.
(onChoked): New function.
(onCanceled): New function.
* src/PieceMessage.cc
(send): If invalidate is true then do nothing, just return.
(createRejectMessage): New function.
(onChoked): New function.
(onCanceled): New function.
* src/RequestMessage.h
(RequestMessage): Rewritten.
(onPush): New function.
(onAbortPiece): New function.
* src/RequestMessage.cc
(onPush): New function.
(onAbortPiece): New function.
Update fd_set when a socket is added or deleted in order to
improve
performance:
* src/DownloadEngine.h
(rfdset): New variable.
(wfdset): New variable.
(updateFdSet): New function.
* src/DownloadEngine.cc
(SetDescriptor::operator()): Use SockCmdMap::value_type.
(AccumulateActiveCommandUuid::operator()): Use
SockCmdMap::value_type.
(waitData): Copy rfdset and wfdset.
(updateFdSet): New function.
(addSocket): Call updateFdSet.
(deleteSocket): Call updateFdSet.
* src/PeerAbstractCommand.h
(beforeSocketCheck): Removed.
* src/PeerAbstractCommand.cc
Modified in order to call executeInternal() even if socket check
and upload limit check fail.
* src/PeerInteractionCommand.h
(keepAlive): Removed.
(sendKeepAlive): New function.
(checkHave): New function.
(beforeSocketCheck): Removed.
* src/PeerInteractionCommand.cc
(executeInternal): Use peerInteraction->checkRequestSlot().
Added
calls to checkHave() and sendKeepAlive().
(keepAlive): Renamed to sendKeepAlive().
(sendKeepAlive): New function.
(beforeSocketCheck): Removed.
(checkHave): New function.
* src/BitfieldMan.cc
(getMissingIndex): Don't call getMissingIndexRandomly() if max
is 0.
(getMissingUnusedIndex): Don't call getMissingIndexRandomly() if
max is
0.
(getMissingIndex): Dont't call getMissingIndexRandomly() if max
is 0.
* src/TorrentMan.h
(UsedPieces): Removed.
(Pieces): New type definition.
* src/Piece.h: Updated doc.
* src/Peer.h
(totalLength): Removed.
* src/Peer.cc
(updateLatency): Fixed the latency calculation.
* src/TorrentMan.cc
(addPeer): Call deleteOldErrorPeers() only if peers.size() is
higher
than or equal to MAX_PEER_LIST_SIZE.
If duplicate is false and peer.size() >= MAX_PEER_LIST_SIZE,
then return false.
(deleteOldErrorPeers): Rewritten.
(deleteUsedPiece): Fixed the miss use of STL remove.
* src/PeerInteraction.h
(Pieces): Removed.
(deleteTimeoutRequestSlot): Removed.
(deleteCompletedRequestSlot): Removed.
(checkRequestSlot): New function.
* src/PeerInteraction.cc
(deleteTimeoutRequestSlot): Merged to checkRequestSlot().
(deleteCompletedRequestSlot): Merged to checkRequestSlot().
(checkRequestSlot): New function.
* src/DownloadEngine.cc
(run): Clear activeSockets before calling waitData().
(waitData): Removed a call to activeSockets.clear().
To add the ability to download several pieces in mix in a
command and
increase the number of request slots according to request-cancel
latency:
* src/PeerInteractionCommand.cc
(executeInternal): The number of messages to be received at a
time
is increased from 10 to 50.
* src/LogFactory
(getInstance): Added NullLogger.
* src/NullLogger.h: New class.
* src/BitfieldMan.h
(getMissingIndex): New function.
* src/BitfieldMan.cc
(getMissingIndex): New function.
* src/TorrentMan.h
(checkOutPiece): New function.
(getMissingPieceIndex): New function.
(getMissingFastPieceIndex): New function.
(getMissingFastPiece): New function.
* src/TorrentMan.cc
(updatePiece): Rewritten using STL.
(syncPiece): Rewritten using STL.
(getMissingPiece): Rewritten using getMissingPieceIndex() and
checkOutPiece().
(getMissingPieceIndex): New function.
(getMissingFastPieceIndex): New function.
(getMissingFastPiece): New function.
(checkOutPiece): New function.
* src/PeerInteraction.h
(Pieces): New type definition.
(piece): Removed.
(pieces): New variable.
(getNewPieceAndSendInterest): Added the "piece" argument.
(abortPiece): Added the "piece" argument.
(abortAllPieces): New function.
(isInRequestSlot): New function.
(hasDownloadPiece): Added the "index" argument.
(setDownloadPiece): Removed.
(getDownloadPiece): Added the "index" argument.
(updatePiece): New function.
(createRequestMessage): Added the "index" argument.
* src/PeerInteraction.cc
(onChoked): Rewritten.
(abortPiece): Rewirtten.
(abortAllPieces): New function.
(deleteTimeoutRequestSlot): Rewritten.
Clarified code a little bit.
(deleteCompletedRequestSlot): Rewritten.
(isInRequestSlot): New function.
(syncPiece): Rewritten.
(updatePiece): New function.
(getNewPieceAndSendInterest): Rewritten.
(addRequests): Rewritten.
(getDownloadPiece): Rewritten.
(hasDownloadPiece): Rewritten.
(createRequestMessage): Added the "index" argument.
* src/common.h
(BITFIELD_LEN_FROM_PIECES): Enclosed the variable in
parentheses.
(DIV_FLOOR): New definition.
* src/PieceMessage.cc
(receivedAction): Update request-piece latency here.
* src/RequestSlot.h
(getLatencyInMillis): New function.
* src/RequestSlot.cc
(isTimeout): Rewritten using getLatencyInMillis.
(getLatencyInMillis): New function.
* src/Piece.h
(operator==): New function.
(getMissingBlockIndex): New function.
* src/Piece.cc
(operator==): New function.
(getMissingBlockIndex): New function.
* src/Peer.h
(DEFAULT_LATENCY): New definition.
(latency): New variable.
(updateLatency): New function.
(getLatency): New function.
* src/Peer.cc
(resetStatus): Reset latecy.
(updateLatency): New function.