Documentation ¶
Overview ¶
Package blockchain provides the tools for encoding data primitives in blockchain structures
Index ¶
- Variables
- func ReadExtensibleString(r *Reader, f func(*Reader) error) (suffix []byte, err error)
- func ReadVarint31(r *Reader) (uint32, error)
- func ReadVarint63(r *Reader) (uint64, error)
- func ReadVarstr31(r *Reader) ([]byte, error)
- func ReadVarstrList(r *Reader) (result [][]byte, err error)
- func WriteExtensibleString(w io.Writer, suffix []byte, f func(io.Writer) error) (int, error)
- func WriteVarint31(w io.Writer, val uint64) (int, error)
- func WriteVarint63(w io.Writer, val uint64) (int, error)
- func WriteVarstr31(w io.Writer, str []byte) (int, error)
- func WriteVarstrList(w io.Writer, l [][]byte) (int, error)
- type Reader
Constants ¶
This section is empty.
Variables ¶
var ErrRange = errors.New("value out of range")
Functions ¶
func ReadExtensibleString ¶
ReadExtensibleString reads a varint31 length prefix and that many bytes from r. It then calls the given function to consume those bytes, returning any unconsumed suffix.
func ReadVarint31 ¶
func ReadVarint63 ¶
func ReadVarstr31 ¶
func ReadVarstrList ¶
ReadVarstrList reads a varint31 length prefix followed by that many varstrs.
func WriteExtensibleString ¶
WriteExtensibleString sends the output of the given function, plus the given suffix, to w, together with a varint31 length prefix.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader wraps a buffer and provides utilities for decoding data primitives in blockchain structures. Its various read calls may return a slice of the underlying buffer.
func NewReader ¶
NewReader constructs a new reader with the provided bytes. It does not create a copy of the bytes, so the caller is responsible for copying the bytes if necessary.