C# Класс Nethereum.ABI.Util.RLP.RLP

Recursive Length Prefix (RLP) encoding.

The purpose of RLP is to encode arbitrarily nested arrays of binary data, and RLP is the main encoding method used to serialize objects in Ethereum. The only purpose of RLP is to encode structure; encoding specific atomic data types (eg. strings, integers, floats) is left up to higher-order protocols; in Ethereum the standard is that integers are represented in big endian binary form. If one wishes to use RLP to encode a dictionary, the two suggested canonical forms are to either use [[k1,v1],[k2,v2]...] with keys in lexicographic order or to use the higher-level Patricia Tree encoding as Ethereum does.

The RLP encoding function takes in an item. An item is defined as follows:

- A string (ie. byte array) is an item - A list of items is an item

For example, an empty string is an item, as is the string containing the word "cat", a list containing any number of strings, as well as more complex data structures like ["cat",["puppy","cow"],"horse",[[]],"pig",[""],"sheep"]. Note that in the context of the rest of this article, "string" will be used as a synonym for "a certain number of bytes of binary data"; no special encodings are used and no knowledge about the content of the strings is implied.

See:

https://github.com/ethereum/wiki/wiki/RLP
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
EMPTY_BYTE_ARRAY byte[]
ZERO_BYTE_ARRAY byte[]

Открытые методы

Метод Описание
ByteArrayToInt ( byte bytes ) : int
Decode ( byte msgData ) : RLPCollection

Parses byte[] message into RLP items

Decode ( byte msgData, int level, int startPosition, int endPosition, int levelToIndex, RLPCollection rlpCollection ) : void

Decodes a message from a starting point to an end point

DecodeFirstElement ( byte msgData, int startPos ) : IRLPElement
EncodeByte ( byte singleByte ) : byte[]
EncodeElement ( byte srcData ) : byte[]
EncodeList ( ) : byte[]
IsNullOrZeroArray ( byte array ) : bool
IsSingleZero ( byte array ) : bool

Приватные методы

Метод Описание
CalculateLength ( int lengthOfLength, byte msgData, int pos ) : int

Описание методов

ByteArrayToInt() публичный статический Метод

public static ByteArrayToInt ( byte bytes ) : int
bytes byte
Результат int

Decode() публичный статический Метод

Parses byte[] message into RLP items
public static Decode ( byte msgData ) : RLPCollection
msgData byte raw RLP data
Результат RLPCollection

Decode() публичный статический Метод

Decodes a message from a starting point to an end point
public static Decode ( byte msgData, int level, int startPosition, int endPosition, int levelToIndex, RLPCollection rlpCollection ) : void
msgData byte
level int
startPosition int
endPosition int
levelToIndex int
rlpCollection RLPCollection
Результат void

DecodeFirstElement() публичный статический Метод

public static DecodeFirstElement ( byte msgData, int startPos ) : IRLPElement
msgData byte
startPos int
Результат IRLPElement

EncodeByte() публичный статический Метод

public static EncodeByte ( byte singleByte ) : byte[]
singleByte byte
Результат byte[]

EncodeElement() публичный статический Метод

public static EncodeElement ( byte srcData ) : byte[]
srcData byte
Результат byte[]

EncodeList() публичный статический Метод

public static EncodeList ( ) : byte[]
Результат byte[]

IsNullOrZeroArray() публичный статический Метод

public static IsNullOrZeroArray ( byte array ) : bool
array byte
Результат bool

IsSingleZero() публичный статический Метод

public static IsSingleZero ( byte array ) : bool
array byte
Результат bool

Описание свойств

EMPTY_BYTE_ARRAY публичное статическое свойство

public static byte[] EMPTY_BYTE_ARRAY
Результат byte[]

ZERO_BYTE_ARRAY публичное статическое свойство

public static byte[] ZERO_BYTE_ARRAY
Результат byte[]