예제 #1
0
        internal NodeId(BigInteger value)
        {
            Value = value;
            Bytes = value.GetBytes();
            if (Bytes.Length < 20)
            {
                var newBytes = new byte[20];
                Buffer.BlockCopy(Bytes, 0, newBytes, newBytes.Length - Bytes.Length, Bytes.Length);
                Bytes = newBytes;
            }

            if (Bytes.Length != 20)
            {
                throw new ArgumentException("The provided value cannot be represented in 160bits", nameof(value));
            }
        }
예제 #2
0
 internal BEncodedString BencodedString()
 {
     return(new BEncodedString(value.GetBytes()));
 }