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
- Variables
- func BytesToInt(out interface{}, in *[]byte)
- func Hash64(in *[]byte) *[]byte
- func IntToBytes(u interface{}) (out *[]byte)
- func ReverseByteOrder(in []byte) (out []byte)
- func Zero(b *[]byte)
- type Address
- type Array
- type Buffer
- type Coder
- type CommonErrors
- type H160
- type H256
- type Hash
- type MerkleTx
- type State
- type Status
- type Streamer
Constants ¶
const ( COIN = 100000000 CENT = 1000000 )
Variables ¶
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
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 IntToBytes ¶
func IntToBytes(u interface{}) (out *[]byte)
IntToBytes converts any integer to a byte slice
func ReverseByteOrder ¶
ReverseByteOrder converts little to big endian and vice versa
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