Skip to content

Latest commit

 

History

History
287 lines (119 loc) · 8.16 KB

consensus_codec.md

File metadata and controls

287 lines (119 loc) · 8.16 KB

Module 0x2::consensus_codec

This module implements the Bitcoin consensus encode/decode functions

Struct Encoder

struct Encoder has copy, drop, store

Struct Decoder

struct Decoder has copy, drop, store

Constants

const ErrorInvalidLength: u64 = 1;

const ErrorOutOfRange: u64 = 3;

const ErrorNonMinimalVarInt: u64 = 2;

Function encoder

Function decoder

public fun decoder(data: vector<u8>): consensus_codec::Decoder

Function unpack_encoder

Function unpack_decoder

Function emit_u64

public fun emit_u64(encoder: &mut consensus_codec::Encoder, v: u64)

Function emit_u32

public fun emit_u32(encoder: &mut consensus_codec::Encoder, v: u32)

Function emit_u16

public fun emit_u16(encoder: &mut consensus_codec::Encoder, v: u16)

Function emit_u8

public fun emit_u8(encoder: &mut consensus_codec::Encoder, v: u8)

Function emit_bool

public fun emit_bool(encoder: &mut consensus_codec::Encoder, v: bool)

Function emit_var_int

public fun emit_var_int(encoder: &mut consensus_codec::Encoder, v: u64)

Function emit_var_slice

Emit a slice of bytes to the encoder with a varint length

public fun emit_var_slice(encoder: &mut consensus_codec::Encoder, v: vector<u8>)

Function peel_var_int

public fun peel_var_int(decoder: &mut consensus_codec::Decoder): u64

Function peel_var_slice

Peel a slice of bytes from the decoder with a varint length

public fun peel_var_slice(decoder: &mut consensus_codec::Decoder): vector<u8>

Function peel_bool

public fun peel_bool(decoder: &mut consensus_codec::Decoder): bool

Function peel_u64

public fun peel_u64(decoder: &mut consensus_codec::Decoder): u64

Function peel_u32

public fun peel_u32(decoder: &mut consensus_codec::Decoder): u32

Function peel_u16

public fun peel_u16(decoder: &mut consensus_codec::Decoder): u16

Function peel_u8

public fun peel_u8(decoder: &mut consensus_codec::Decoder): u8