public PeerConnector(IPeerEventDataFactory peerEventDataFactory, ITcpSocketHelper tcpSocketHelper, string peerId, TorrentInfoSingle torrentInfo)
        {
            if (torrentInfo.InfoHash.Length != Constants.InfoHashLength)
            {
                throw new ArgumentException($"Info hash must be {Constants.InfoHashLength} bytes");
            }

            if (peerId.Length != Constants.PeerIdLength)
            {
                throw new ArgumentException($"Peer id must be {Constants.PeerIdLength} bytes");
            }

            PeerEventDataFactory = peerEventDataFactory;
            TcpSocketHelper      = tcpSocketHelper;
            TorrentInfo          = torrentInfo;
            PeerId = peerId;
        }
Esempio n. 2
0
 public Torrent(string announceUrl, TorrentInfoSingle info)
 {
     AnnounceUrl = announceUrl;
     Info        = info;
     Left        = info.Length;
 }
        public SocketPeer(IPeerEventDataFactory peerEventDataFactory, Peer peer, Socket socket, TorrentInfoSingle torrentInfo, string peerId)
        {
            if (torrentInfo.InfoHash.Length != Constants.InfoHashLength)
            {
                throw new ArgumentException($"Info hash must be {Constants.InfoHashLength} bytes");
            }

            if (peerId.Length != Constants.PeerIdLength)
            {
                throw new ArgumentException($"Peer id must be {Constants.PeerIdLength} bytes");
            }

            PeerEventDataFactory = peerEventDataFactory;
            Peer        = peer;
            Socket      = socket;
            PeerId      = peerId;
            InfoHash    = torrentInfo.InfoHash;
            PieceLength = torrentInfo.PieceLength;
            PieceAmount = torrentInfo.PieceHashes.Count;
        }