Пример #1
0
 public void Encode(Span <byte> input)
 {
     if (input == null || input.Length == 0)
     {
         WriteByte(EmptyArrayByte);
     }
     else if (input.Length == 1 && input[0] < 128)
     {
         WriteByte(input[0]);
     }
     else if (input.Length < 56)
     {
         byte smallPrefix = (byte)(input.Length + 128);
         WriteByte(smallPrefix);
         Write(input);
     }
     else
     {
         int  lengthOfLength = Rlp.LengthOfLength(input.Length);
         byte prefix         = (byte)(183 + lengthOfLength);
         WriteByte(prefix);
         WriteEncodedLength(input.Length);
         Write(input);
     }
 }
Пример #2
0
        public void StartSequence(int contentLength)
        {
            byte prefix;

            if (contentLength < 56)
            {
                prefix = (byte)(192 + contentLength);
                WriteByte(prefix);
            }
            else
            {
                prefix = (byte)(247 + Rlp.LengthOfLength(contentLength));
                WriteByte(prefix);
                WriteEncodedLength(contentLength);
            }
        }