Class PiecesViewBase.PEPieceUploading

  • All Implemented Interfaces:
    PEPiece
    Enclosing class:
    PiecesViewBase

    public class PiecesViewBase.PEPieceUploading
    extends java.lang.Object
    implements PEPiece
    • Field Detail

      • piece_number

        private final int piece_number
      • blocks

        private final boolean[] blocks
      • complete

        private boolean complete
      • last_active

        private volatile long last_active
    • Method Detail

      • getLength

        public int getLength()
        Specified by:
        getLength in interface PEPiece
      • getBlockNumber

        public int getBlockNumber​(int offset)
        Specified by:
        getBlockNumber in interface PEPiece
        Parameters:
        offset - int bytes into piece
        Returns:
        block int number corresponding to given offset
      • getBlockSize

        public int getBlockSize​(int block_index)
        Specified by:
        getBlockSize in interface PEPiece
      • addUploading

        private void addUploading​(boolean[] b,
                                  java.util.Set<java.lang.String> latest_peers)
      • readyToRemove

        private boolean readyToRemove()
      • getUploadPeers

        public CopyOnWriteSet<java.lang.String> getUploadPeers()
      • getCreationTime

        public long getCreationTime()
        Description copied from interface: PEPiece
        The time the pePiece was [re]created
        Specified by:
        getCreationTime in interface PEPiece
      • getTimeSinceLastActivity

        public long getTimeSinceLastActivity()
        Description copied from interface: PEPiece
        How many ms since a write to the piece, or since the piece was created if no last write time is known. The return value will be 0 when there's no writes and the piece is new.
        Specified by:
        getTimeSinceLastActivity in interface PEPiece
        Returns:
        long
      • addWrite

        public void addWrite​(int blockNumber,
                             java.lang.String sender,
                             byte[] hash,
                             boolean correct)
        Description copied from interface: PEPiece
        record details of a piece's blocks that have been completed for bad peer detection purposes
        Specified by:
        addWrite in interface PEPiece
      • getAndMarkBlocks

        public int[] getAndMarkBlocks​(PEPeer peer,
                                      int nbWanted,
                                      int[] request_hint,
                                      boolean reverse_order)
        Specified by:
        getAndMarkBlocks in interface PEPiece
      • getRealTimeData

        public java.lang.Object getRealTimeData()
        Specified by:
        getRealTimeData in interface PEPiece
      • setRealTimeData

        public void setRealTimeData​(java.lang.Object o)
        Specified by:
        setRealTimeData in interface PEPiece
      • setRequested

        public boolean setRequested​(PEPeer peer,
                                    int blockNumber)
        Specified by:
        setRequested in interface PEPiece
      • clearRequested

        public void clearRequested​(int blocNumber)
        Specified by:
        clearRequested in interface PEPiece
      • isRequested

        public boolean isRequested​(int blockNumber)
        Specified by:
        isRequested in interface PEPiece
      • isRequested

        public boolean isRequested()
        Specified by:
        isRequested in interface PEPiece
      • isDownloaded

        public boolean isDownloaded​(int blockNumber)
        Specified by:
        isDownloaded in interface PEPiece
      • setDownloaded

        public void setDownloaded​(int offset)
        Specified by:
        setDownloaded in interface PEPiece
      • clearDownloaded

        public void clearDownloaded​(int offset)
        Specified by:
        clearDownloaded in interface PEPiece
      • isDownloaded

        public boolean isDownloaded()
        Specified by:
        isDownloaded in interface PEPiece
      • getDownloaded

        public boolean[] getDownloaded()
        Specified by:
        getDownloaded in interface PEPiece
      • getReservedBy

        public java.lang.String getReservedBy()
        Specified by:
        getReservedBy in interface PEPiece
      • setReservedBy

        public void setReservedBy​(java.lang.String peer)
        Specified by:
        setReservedBy in interface PEPiece
      • getResumePriority

        public int getResumePriority()
        Specified by:
        getResumePriority in interface PEPiece
        Returns:
        int ResumePriority (startPriority + resuming adjustments)
      • setResumePriority

        public void setResumePriority​(int p)
        Specified by:
        setResumePriority in interface PEPiece
        Parameters:
        p - the Resume Priority to set, for display purposes
      • getWriters

        public java.lang.String[] getWriters()
        Specified by:
        getWriters in interface PEPiece
      • setWritten

        public void setWritten​(java.lang.String peer,
                               int blockNumber)
        Specified by:
        setWritten in interface PEPiece
      • isWritten

        public boolean isWritten()
        Specified by:
        isWritten in interface PEPiece
      • isWritten

        public boolean isWritten​(int blockNumber)
        Specified by:
        isWritten in interface PEPiece
      • getSpeed

        public int getSpeed()
        Specified by:
        getSpeed in interface PEPiece
      • setSpeed

        public void setSpeed​(int speed)
        Specified by:
        setSpeed in interface PEPiece
      • reset

        public void reset()
        Specified by:
        reset in interface PEPiece
      • getString

        public java.lang.String getString()
        Specified by:
        getString in interface PEPiece