Documentation ¶
Overview ¶
Package encoding provides byte serialization and deserialization of trie and ledger structs.
Index ¶
- Constants
- func CheckType(rawInput []byte, expectedType uint8) (rest []byte, err error)
- func CheckVersion(rawInput []byte) (rest []byte, version uint16, err error)
- func DecodeKey(encodedKey []byte) (*ledger.Key, error)
- func DecodeKeyPart(encodedKeyPart []byte) (*ledger.KeyPart, error)
- func DecodePath(encodedPath []byte) (ledger.Path, error)
- func DecodePayload(encodedPayload []byte) (*ledger.Payload, error)
- func DecodeTrieBatchProof(encodedBatchProof []byte) (*ledger.TrieBatchProof, error)
- func DecodeTrieProof(encodedProof []byte) (*ledger.TrieProof, error)
- func DecodeTrieUpdate(encodedTrieUpdate []byte) (*ledger.TrieUpdate, error)
- func DecodeValue(encodedValue []byte) (ledger.Value, error)
- func EncodeKey(k *ledger.Key) []byte
- func EncodeKeyPart(kp *ledger.KeyPart) []byte
- func EncodePath(p ledger.Path) []byte
- func EncodePayload(p *ledger.Payload) []byte
- func EncodeTrieBatchProof(bp *ledger.TrieBatchProof) []byte
- func EncodeTrieProof(p *ledger.TrieProof) []byte
- func EncodeTrieUpdate(t *ledger.TrieUpdate) []byte
- func EncodeValue(v ledger.Value) []byte
- type Type
Constants ¶
const ( // TypeUnknown - unknown type TypeUnknown = iota // TypeState - type for State TypeState // TypeKeyPart - type for KeyParts (a subset of key) TypeKeyPart // TypeKey - type for Keys (unique identifier to reference a location in ledger) TypeKey // TypeValue - type for Ledger Values TypeValue // TypePath - type for Paths (trie storage location of a key value pair) TypePath // TypePayload - type for Payloads (stored at trie nodes including key value pair ) TypePayload // TypeProof type for Proofs // (all data needed to verify a key value pair at specific state) TypeProof // TypeBatchProof - type for BatchProofs TypeBatchProof // TypeQuery - type for ledger query TypeQuery // TypeUpdate - type for ledger update TypeUpdate // TypeTrieUpdate - type for trie update TypeTrieUpdate )
const Version = uint16(0)
Version captures the maximum version of encoding that this code supports in other words this code encodes the data with the latest version and can only decode data with version smaller or equal to this value bumping this number prevents older versions of the code to deal with the newer version of data codes should be updated with backward compatibility if needed
Variables ¶
This section is empty.
Functions ¶
func CheckType ¶
CheckType extracts encoding byte from a raw encoded message checks it against the supported versions and returns the rest of rawInput (excluding encDecVersion bytes)
func CheckVersion ¶
CheckVersion extracts encoding bytes from a raw encoded message checks it against the supported versions and returns the rest of rawInput (excluding encDecVersion bytes)
func DecodeKeyPart ¶
DecodeKeyPart constructs a key part from an encoded key part
func DecodePath ¶
DecodePath constructs a path value using an encoded byte slice
func DecodePayload ¶
DecodePayload construct a payload from an encoded byte slice
func DecodeTrieBatchProof ¶
func DecodeTrieBatchProof(encodedBatchProof []byte) (*ledger.TrieBatchProof, error)
DecodeTrieBatchProof constructs a batch proof from an encoded byte slice
func DecodeTrieProof ¶
DecodeTrieProof construct a proof from an encoded byte slice
func DecodeTrieUpdate ¶
func DecodeTrieUpdate(encodedTrieUpdate []byte) (*ledger.TrieUpdate, error)
DecodeTrieUpdate construct a trie update from an encoded byte slice
func DecodeValue ¶
DecodeValue constructs a ledger value using an encoded byte slice
func EncodeKeyPart ¶
EncodeKeyPart encodes a key part into a byte slice
func EncodePayload ¶
EncodePayload encodes a ledger payload
func EncodeTrieBatchProof ¶
func EncodeTrieBatchProof(bp *ledger.TrieBatchProof) []byte
EncodeTrieBatchProof encodes a batch proof into a byte slice
func EncodeTrieProof ¶
EncodeTrieProof encodes the content of a proof into a byte slice
func EncodeTrieUpdate ¶
func EncodeTrieUpdate(t *ledger.TrieUpdate) []byte
EncodeTrieUpdate encodes a trie update struct
func EncodeValue ¶
EncodeValue encodes a value into a byte slice