utils

package
v0.0.0-...-25c57ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2018 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IoMaxSize = 1024
	MaxSize   = 0x02000000
)
View Source
const (
	HashSize          = 32
	MaxHashStringSize = HashSize * 2
)

Variables

This section is empty.

Functions

func DecodeHash

func DecodeHash(src string) (bytes []byte, err error)

func DecodeVariableLengthInteger

func DecodeVariableLengthInteger(raw []byte) (cnt int, cntSize int)

func GetUint64FromReder

func GetUint64FromReder(r io.Reader) (uint64, error)

func RandomUint64

func RandomUint64() (uint64, error)

func ReadVarBytes

func ReadVarBytes(r io.Reader, size uint32, maxAllowed uint32, fieldName string) ([]byte, error)

func ReadVarInt

func ReadVarInt(r io.Reader, size uint32) (uint64, error)

func ReadVarString

func ReadVarString(r io.Reader, size uint32) (string, error)

func ToHash256String

func ToHash256String(data []byte) string

func ToHexString

func ToHexString(data []byte) string

func VarIntSerializeSize

func VarIntSerializeSize(val uint64) int

func WriteVarBytes

func WriteVarBytes(w io.Writer, size uint32, bytes []byte) error

func WriteVarInt

func WriteVarInt(w io.Writer, size uint32, val uint64) error

func WriteVarString

func WriteVarString(w io.Writer, size uint32, str string) error

Types

type BinaryFreeList

type BinaryFreeList chan []byte
var BinarySerializer BinaryFreeList = make(chan []byte, IoMaxSize)

func (BinaryFreeList) BorrowFront8

func (b BinaryFreeList) BorrowFront8() (buf []byte)

func (BinaryFreeList) PutUint16

func (b BinaryFreeList) PutUint16(w io.Writer, byteOrder binary.ByteOrder, val uint16) error

func (BinaryFreeList) PutUint32

func (b BinaryFreeList) PutUint32(w io.Writer, byteOrder binary.ByteOrder, val uint32) error

func (BinaryFreeList) PutUint64

func (b BinaryFreeList) PutUint64(w io.Writer, byteOrder binary.ByteOrder, val uint64) error

func (BinaryFreeList) PutUint8

func (b BinaryFreeList) PutUint8(w io.Writer, val uint8) error

func (BinaryFreeList) Return

func (b BinaryFreeList) Return(buf []byte)

Return puts the provided byte slice back on the free list. The buffer MUST have been obtained via the Borrow function and therefore have a cap of 8.

func (BinaryFreeList) Uint16

func (b BinaryFreeList) Uint16(r io.Reader, byteOrder binary.ByteOrder) (uint16, error)

func (BinaryFreeList) Uint32

func (b BinaryFreeList) Uint32(r io.Reader, byteOrder binary.ByteOrder) (uint32, error)

func (BinaryFreeList) Uint64

func (b BinaryFreeList) Uint64(r io.Reader, byteOrder binary.ByteOrder) (uint64, error)

func (BinaryFreeList) Uint8

func (b BinaryFreeList) Uint8(r io.Reader) (uint8, error)

type Hash

type Hash [HashSize]byte

func BytesToHash

func BytesToHash(bytes []byte) (hash *Hash, err error)

func GetHashFromStr

func GetHashFromStr(hashStr string) (hash *Hash, err error)

func HashFromString

func HashFromString(hexString string) *Hash

func (*Hash) GetCloneBytes

func (hash *Hash) GetCloneBytes() []byte

func (*Hash) IsEqual

func (hash *Hash) IsEqual(target *Hash) bool

func (*Hash) SetBytes

func (hash *Hash) SetBytes(bytes []byte) error

func (*Hash) ToString

func (hash *Hash) ToString() string

type HashFunc

type HashFunc func() (hash *Hash, height int32, err error)

type LookupFunc

type LookupFunc func(string) ([]net.IP, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL