Esempio n. 1
0
        public static string Format(IRLPElement element)
        {
            var output = new StringBuilder();

            if (element == null)
            {
                throw new Exception("RLPElement object can't be null");
            }
            var rlpCollection = element as RLPCollection;

            if (rlpCollection != null)
            {
                output.Append("[");
                foreach (var innerElement in rlpCollection)
                {
                    Format(innerElement);
                }
                output.Append("]");
            }
            else
            {
                output.Append(element.RLPData.ToHex() + ", ");
            }
            return(output.ToString());
        }
Esempio n. 2
0
 public bool RlpCompare(IRlpType rlpType, IRLPElement iRLPElement)
 {
     if (rlpType is RlpList vCollection)
     {
         if (iRLPElement is RLPCollection nCollection && vCollection.Count == nCollection.Count)
         {
             for (var i = 0; i < vCollection.Count; i++)
             {
                 if (!RlpCompare(vCollection[i], nCollection[i]))
                 {
                     return(false);
                 }
             }
         }
         else
         {
             return(false);
         }
     }
Esempio n. 3
0
 public static string Format(IRLPElement element)
 {
     var output = new StringBuilder();
     if (element == null)
         throw new Exception("RLPElement object can't be null");
     var rlpCollection = element as RLPCollection;
     if (rlpCollection != null)
     {
         output.Append("[");
         foreach (var innerElement in rlpCollection)
             Format(innerElement);
         output.Append("]");
     }
     else
     {
         output.Append(element.RLPData.ToHex() + ", ");
     }
     return output.ToString();
 }
Esempio n. 4
0
        public IRlpItem Decode(byte[] bytes)
        {
            IRLPElement rLPElement = RLP.Decode(bytes);

            return(new RlpItem(rLPElement.RLPData));
        }