示例#1
0
        public DataBlock(string sha256, UInt32 length, DataBlockFrom from)
        {
            this.from   = from;
            this.sha256 = sha256;
            this.data   = new byte[length];
            UInt32 p = length / 50;
            var    m = length % 50;

            if (m != 0)
            {
                p++;
            }
            this.piecetag = new byte[p];
        }
示例#2
0
        public DataBlock newOrGet(string sha256, UInt32 length, DataBlockFrom from)
        {
            foreach (var b in blocks)
            {
                if (sha256.ToUpper() == b.sha256.ToUpper() && b.from == from)
                {
                    return(b);
                }
            }
            var nb = new DataBlock(sha256, (UInt32)length, from);

            this.AddBlock(nb);
            return(nb);
        }