Documentation ¶
Index ¶
- Constants
- Variables
- func ANDBytes(a, b []byte) []byte
- func BitIndexes(data []byte) []uint32
- func BuildMerkleRoot(hashs []*crypto.HashType) []*crypto.HashType
- func Equal(a []byte, b []byte) bool
- func FromHex(data string) ([]byte, error)
- func FromInt16(v int16) []byte
- func FromInt32(v int32) []byte
- func FromInt64(v int64) []byte
- func FromUint16(v uint16) []byte
- func FromUint32(v uint32) []byte
- func FromUint64(v uint64) []byte
- func HashBytes(a []byte) uint32
- func Hex(data []byte) string
- func HomeDir() string
- func InArray(obj interface{}, array interface{}) bool
- func Int16(data []byte) int16
- func Int32(data []byte) int32
- func Int64(data []byte) int64
- func IsPrefixed(s, prefix []byte) bool
- func Less(a []byte, b []byte) bool
- func ORBytes(a, b []byte) []byte
- func PrettyPrint(obj interface{}) string
- func ReadBytes(r io.Reader, data []byte) error
- func ReadBytesOfLength(r io.Reader, l uint32) ([]byte, error)
- func ReadHex(r io.Reader) (string, error)
- func ReadInt16(r io.Reader) (int16, error)
- func ReadInt32(r io.Reader) (int32, error)
- func ReadInt64(r io.Reader) (int64, error)
- func ReadInt8(r io.Reader) (int8, error)
- func ReadUint16(r io.Reader) (uint16, error)
- func ReadUint32(r io.Reader) (uint32, error)
- func ReadUint64(r io.Reader) (uint64, error)
- func ReadUint8(r io.Reader) (uint8, error)
- func ReadUvarint(r io.Reader) (uint64, error)
- func ReadVarBytes(r io.Reader) ([]byte, error)
- func ReadVarint(r io.Reader) (int64, error)
- func Uint16(data []byte) uint16
- func Uint32(data []byte) uint32
- func Uint64(data []byte) uint64
- func WriteBytes(w io.Writer, v []byte) error
- func WriteElements(w io.Writer, elements ...interface{}) error
- func WriteHex(w io.Writer, s string) error
- func WriteInt16(w io.Writer, v int16) error
- func WriteInt32(w io.Writer, v int32) error
- func WriteInt64(w io.Writer, v int64) error
- func WriteInt8(w io.Writer, v int8) error
- func WriteUint16(w io.Writer, v uint16) error
- func WriteUint32(w io.Writer, v uint32) error
- func WriteUint64(w io.Writer, v uint64) error
- func WriteUint8(w io.Writer, v uint8) error
- func WriteUvarint(w io.Writer, v uint64) error
- func WriteVarBytes(w io.Writer, v []byte) error
- func WriteVarint(w io.Writer, v int64) error
- type Dag
- type Hash
- type HexHash
- type LessFunc
- type Node
- type PriorityQueue
- func (pq *PriorityQueue) Items(i int) interface{}
- func (pq *PriorityQueue) Len() int
- func (pq *PriorityQueue) Less(i, j int) bool
- func (pq *PriorityQueue) Pop() interface{}
- func (pq *PriorityQueue) Push(x interface{})
- func (pq *PriorityQueue) SetLessFunc(lessFunc LessFunc)
- func (pq *PriorityQueue) Swap(i, j int)
Constants ¶
const ( // CommandSize is the fixed size of all commands (MessageHeader.Code) in the common message // header. Shorter commands must be zero padded. CommandSize = 4 )
Variables ¶
var ( ErrKeyNotFound = errors.New("key not found in dag") ErrKeyIsExisted = errors.New("key is exist in dag") )
error
var ReadByte func(io.Reader) (byte, error)
ReadByte reads single byte.
var WriteByte func(io.Writer, byte) error
WriteByte wtires single byte.
Functions ¶
func ANDBytes ¶ added in v0.5.0
ANDBytes ands one by one. It works on all architectures, independent if it supports unaligned read/writes or not.
func BitIndexes ¶ added in v0.5.0
BitIndexes return marked bit indexes.
func BuildMerkleRoot ¶
BuildMerkleRoot build transaction merkle tree
root = h1234 = h(h12 + h34) / \ h12 = h(h1 + h2) h34 = h(h3 + h4) / \ / \ h1 = h(tx1) h2 = h(tx2) h3 = h(tx3) h4 = h(tx4)
The above stored as a linear array is as follows:
[h1 h2 h3 h4 h12 h34 root]
func InArray ¶
func InArray(obj interface{}, array interface{}) bool
InArray return if there is an element in the array
func IsPrefixed ¶
IsPrefixed returns if s has the passed prefix
func ORBytes ¶ added in v0.5.0
ORBytes ors one by one. It works on all architectures, independent if it supports unaligned read/writes or not.
func PrettyPrint ¶
func PrettyPrint(obj interface{}) string
PrettyPrint prints all types with pretty ident and format
func ReadBytesOfLength ¶
ReadBytesOfLength reads specified length of []byte via reader.
func ReadVarBytes ¶
ReadVarBytes reads variable length of []byte via reader.
func WriteBytes ¶
WriteBytes writes fix length of bytes.
func WriteElements ¶
WriteElements writes multiple items to w. It is equivalent to multiple calls to writeElement.
func WriteUvarint ¶
WriteUvarint writes unit64 value.
func WriteVarBytes ¶
WriteVarBytes writes variable length of bytes.
Types ¶
type Dag ¶ added in v0.5.0
type Dag struct {
// contains filtered or unexported fields
}
Dag define a dag struct
func (*Dag) GetRootNodes ¶ added in v0.5.0
GetRootNodes get root nodes in dag
func (*Dag) IsCirclular ¶ added in v0.5.0
IsCirclular check if circlular in dag
type Hash ¶
type Hash []byte
Hash by Sha3-256
type Node ¶ added in v0.5.0
type Node struct {
// contains filtered or unexported fields
}
Node define a node struct
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue define a priority queue.
func NewPriorityQueue ¶
func NewPriorityQueue(lessFunc LessFunc) *PriorityQueue
NewPriorityQueue create a new PriorityQueue
func (*PriorityQueue) Items ¶
func (pq *PriorityQueue) Items(i int) interface{}
Items return item in queue at index i.
func (*PriorityQueue) Len ¶
func (pq *PriorityQueue) Len() int
Len returns the length of items. It implemented heap.Interface.
func (*PriorityQueue) Less ¶
func (pq *PriorityQueue) Less(i, j int) bool
Less implemented the heap.Interface.
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
Pop removes the highest priority item from the priority
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x interface{})
Push pushes the passed item onto the priority queue.
func (*PriorityQueue) SetLessFunc ¶
func (pq *PriorityQueue) SetLessFunc(lessFunc LessFunc)
SetLessFunc sets the compare function for the priority queue
func (*PriorityQueue) Swap ¶
func (pq *PriorityQueue) Swap(i, j int)
Swap swaps the items in the priority queue. It implemented heap.Interface.