Serialization Primitives

Avalanche utilise une représentation simple, uniforme et élégante pour toutes les données internes. Ce document décrit comment les types de donnée primitifs sont encodés sur la plateforme Avalanche. Les transactions sont codées en fonction de ces types primitifs de base.

Byte

Bytes are packed as-is into the message payload.

Example:

Packing:
    0x01
Results in:
    [0x01]

Short

Shorts are packed in BigEndian format into the message payload.

Example:

Packing:
    0x0102
Results in:
    [0x01, 0x02]

Integer

Integers are 32-bit values packed in BigEndian format into the message payload.

Example:

Long Integers

Long integers are 64-bit values packed in BigEndian format into the message payload.

Example:

IP Addresses

IP addresses are represented as 16-byte IPv6 format, with the port appended into the message payload as a Short. IPv4 addresses are padded with 12 bytes of leading 0x00s.

IPv4 example:

IPv6 example:

Fixed-Length Array

Fixed-length arrays, whose length is known ahead of time and by context, are packed in order.

Byte array example:

Integer array example:

Variable Length Array

The length of the array is prefixed in Integer format, followed by the packing of the array contents in Fixed Length Array format.

Byte array example:

Int array example:

String

A String is packed similarly to a variable-length byte array. However, the length prefix is a short rather than an int. Strings are encoded in UTF-8 format.

Example:

Mis à jour

Ce contenu vous a-t-il été utile ?