public Source(DownloadSourceCollection parent, byte[] peerID, string fileName, RIndexedHashtable<string, string> metaData, string comment, byte rating, byte[] sectorsMap)
            {
                if (parent == null)
                    throw new ArgumentNullException("parent");
                if (peerID == null)
                    throw new ArgumentNullException("peerID");
                if (peerID.Length != 48)
                    throw new ArgumentException();
                if (fileName == null)
                    throw new ArgumentNullException("fileName");
                if (metaData == null)
                    throw new ArgumentNullException("metaData");
                if (comment == null)
                    throw new ArgumentNullException("comment");
                if (rating > 3)
                    throw new ArgumentOutOfRangeException("rating");

                m_MetaData = new DownloadSourceMetaDataCollection(parent, metaData);
                m_PeerID = peerID;
                m_PeerIDString = Core.ByteArrayToString(m_PeerID);
                m_FileName = fileName;
                m_MetaData = new DownloadSourceMetaDataCollection(parent, metaData);
                m_Comment = comment;
                m_Rating = rating;
                m_SectorsMap = sectorsMap;
                m_HasInformation = true;
            }
            public Source(DownloadSourceCollection parent, byte[] peerID, byte[] sectorsMap)
            {
                if (parent == null)
                    throw new ArgumentNullException("parent");
                if (peerID == null)
                    throw new ArgumentNullException("peerID");
                if (peerID.Length != 48)
                    throw new ArgumentException();

                m_MetaData = new DownloadSourceMetaDataCollection(parent);
                m_PeerID = peerID;
                m_PeerIDString = Core.ByteArrayToString(m_PeerID);
                m_SectorsMap = sectorsMap;
            }
Esempio n. 3
0
        private void Initialize(byte[] fileHash)
        {
            if (fileHash == null)
                throw new ArgumentNullException("fileHash");
            if (fileHash.Length != 64)
                throw new ArgumentException();

            m_Sources = new DownloadSourceCollection(Core.DownloadsAndQueue);
            m_MetaData = new DownloadMetaDataCollection(Core.DownloadsAndQueue);
            m_FileHash = fileHash;
            m_FileHashString = Core.ByteArrayToString(m_FileHash);
            m_OnceHashedFileHash = ComputeHashes.SHA512Compute(m_FileHash);
            m_OnceHashedFileHashString = Core.ByteArrayToString(m_OnceHashedFileHash);
            m_TwiceHashedFileHash = ComputeHashes.SHA512Compute(m_OnceHashedFileHash);
            m_TwiceHashedFileHashString = Core.ByteArrayToString(m_TwiceHashedFileHash);
            m_ThriceHashedFileHash = ComputeHashes.SHA512Compute(m_TwiceHashedFileHash);
            m_ThriceHashedFileHashString = Core.ByteArrayToString(m_ThriceHashedFileHash);
            m_SourceSearchFloodingHash = Core.GenerateFloodingHash();
            m_SourceSearchPeerID = Core.GenerateIDOrHash();
            m_SourceSearchID = Core.GenerateIDOrHash();
            m_SourceSearchResponsePeerID = Core.GenerateIDOrHash();
            m_DownloadPeerID = Core.GenerateIDOrHash();
            m_DownloadID = Core.GenerateIDOrHash();
            m_DownloadIDString = Core.ByteArrayToString(m_DownloadID);
        }