core

package
v0.0.1-0...-74edd6f Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2018 License: Unlicense Imports: 3 Imported by: 0

Documentation

Overview

Package core is a library that aggregates common elements used by other parts of Duo, as part of the structure required to avoid circular imports. There is interfaces, some basic implementations and a few utility functions.

Index

Constants

View Source
const (
	COIN = 100000000
	CENT = 1000000
)

Variables

View Source
var Errors = CommonErrors{
	"nil receiver", "nil parameter", "nil buffer", "zero length parameter", "index out of bounds", "invalid type", "zero length buffer",
}

Errors gives a short readable reference to indicate a common error string

View Source
var StringCodings = []string{
	"bytes",
	"string",
	"decimal",
	"hex",
	"base32",
	"base58check",
	"base64",
}

StringCodings is a list of the names of encoding types for the stringer

Functions

func BytesToInt

func BytesToInt(out interface{}, in *[]byte)

BytesToInt takes up to 8 byte long byte slice and a pointer to the type of int wanted back

func Hash64

func Hash64(in *[]byte) *[]byte

Hash64 takes a byte slice and produces a 4 byte byte slice

func IntToBytes

func IntToBytes(u interface{}) (out *[]byte)

IntToBytes converts any integer to a byte slice

func ReverseByteOrder

func ReverseByteOrder(in []byte) (out []byte)

ReverseByteOrder converts little to big endian and vice versa

func Zero

func Zero(b *[]byte)

Zero makes all the bytes in a slice zero

Types

type Address

type Address string

Address is used as the key for searching for public keys (addresses also), scripts, transactions and blocks, generated using the hash160 function, which is a sha256 followed by ripemd160.

type Array

type Array interface {
	SetElem(index int, in interface{}) Array
	GetElem(index int) (out interface{})
	Len() int
}

Array is an interface to access elements of a buffer

type Buffer

type Buffer interface {
	Bytes() (out *[]byte)
	Copy(in *[]byte) Buffer
	Zero() Buffer
	Free() Buffer
	IsEqual(*[]byte) bool
}

Buffer is a generic interface for []byte buffers

type Coder

type Coder interface {
	GetCoding() (out *string)
	SetCoding(in string) Coder
	ListCodings() (out *[]string)
}

Coder is an interface for encoding raw bytes in various base number formats

type CommonErrors

type CommonErrors struct {
	NilRec, NilParam, NilBuf, ZeroLen, OutOfBounds, InvalidType, ZeroLenBuf string
}

CommonErrors are common error values from library functions

type H160

type H160 interface {
	GetAddress() Address
}

H160 is a 20 byte hash created with hash160.Sum that is used as a key for scripts and addresses

type H256

type H256 interface {
	GetHash() Hash
}

H256 is a 32 byte hash created with SHA256 that is used for transactions, blocks, and message hashes

type Hash

type Hash string

Hash is a 256 byte hash stored as a string for use with maps, used for block hashes, transaction hashes, message hashes, and other things

type MerkleTx

type MerkleTx struct {
	HashBlock    []byte
	MerkleBranch []byte
	Index        int64
	// contains filtered or unexported fields
}

MerkleTx is the merkle tree hash data for a transaction

type State

type State struct {
	Status string
	// contains filtered or unexported fields
}

State is a base status/error object, that can be embedded in any other type to proide status notifications

func NewStatus

func NewStatus() *State

NewStatus creates a new Status object

func (*State) Error

func (r *State) Error() string

Error implements the error interface

func (*State) NewIf

func (r *State) NewIf() *State

NewIf creates a new Status object

func (*State) OK

func (r *State) OK() bool

OK returns true if there is no error

func (*State) SetStatus

func (r *State) SetStatus(s string) Status

SetStatus is a

func (*State) SetStatusIf

func (r *State) SetStatusIf(err error) Status

SetStatusIf is a

func (*State) UnsetStatus

func (r *State) UnsetStatus() Status

UnsetStatus is a

type Status

type Status interface {
	SetStatus(string) Status
	SetStatusIf(error) Status
	UnsetStatus() Status
	OK() bool
}

Status keeps track of errors on an ongoing basis and hooks into the logger which fills with snapshots of data state for debugging

type Streamer

type Streamer interface {
	Freeze() (out *[]byte)
	Thaw(in *[]byte) Streamer
}

Streamer is an interface for serialising data

Jump to

Keyboard shortcuts

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