common

package
v0.0.0-...-640f24c Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2018 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ADDR_LEN = 20
View Source
const (
	Decimal = 100000000
)
View Source
const UINT256_SIZE = 32

Variables

This section is empty.

Functions

func BytesReverse

func BytesReverse(u []byte) []byte

func BytesToInt16

func BytesToInt16(b []byte) int16

func CompareHeight

func CompareHeight(blockHeight uint64, heights []uint64) bool

func FileExisted

func FileExisted(filename string) bool

func GetCompactUint

func GetCompactUint(buf []byte) (uint64, uint8)

func GetNonce

func GetNonce() uint64

func HexToBytes

func HexToBytes(value string) ([]byte, error)

func IntToBytes

func IntToBytes(n int) []byte

func IsEqualBytes

func IsEqualBytes(b1 []byte, b2 []byte) bool

func SetCompactUint

func SetCompactUint(num uint64) []byte

TODO Fix the return value to the correct number

func ToHexString

func ToHexString(data []byte) string

Types

type Address

type Address [ADDR_LEN]byte

func AddressFromBase58

func AddressFromBase58(encoded string) (Address, error)

func AddressParseFromBytes

func AddressParseFromBytes(f []byte) (Address, error)

func ToCodeHash

func ToCodeHash(code []byte) Address

func (*Address) Deserialize

func (self *Address) Deserialize(r io.Reader) error

func (*Address) Serialize

func (self *Address) Serialize(w io.Writer) error

func (*Address) ToBase58

func (f *Address) ToBase58() string

func (*Address) ToHexString

func (self *Address) ToHexString() string

type CompactUint

type CompactUint struct {
	// contains filtered or unexported fields
}

type Fixed64

type Fixed64 int64

the 64 bit fixed-point number, precise 10^-8

func FromDecimal

func FromDecimal(value int64) Fixed64

func (*Fixed64) Deserialize

func (f *Fixed64) Deserialize(r io.Reader) error

func (Fixed64) GetData

func (f Fixed64) GetData() int64

func (*Fixed64) Serialize

func (f *Fixed64) Serialize(w io.Writer) error

func (Fixed64) String

func (f Fixed64) String() string

type Inventory

type Inventory interface {
	//sig.SignableData
	Hash() Uint256
	Verify() error
	Type() InventoryType
}

TODO: temp inventory

type InventoryType

type InventoryType byte
const (
	TRANSACTION InventoryType = 0x01
	BLOCK       InventoryType = 0x02
	CONSENSUS   InventoryType = 0xe0
)

type MerkleTree

type MerkleTree struct {
	Depth uint
	Root  *MerkleTreeNode
}

func NewMerkleTree

func NewMerkleTree(hashes []Uint256) (*MerkleTree, error)

use []Uint256 to create a new MerkleTree

type MerkleTreeNode

type MerkleTreeNode struct {
	Hash  Uint256
	Left  *MerkleTreeNode
	Right *MerkleTreeNode
}

func (*MerkleTreeNode) IsLeaf

func (t *MerkleTreeNode) IsLeaf() bool

type Uint256

type Uint256 [UINT256_SIZE]uint8

func ComputeRoot

func ComputeRoot(hashes []Uint256) (Uint256, error)

input a []uint256, create a MerkleTree & calc the root hash

func Uint256ParseFromBytes

func Uint256ParseFromBytes(f []byte) (Uint256, error)

func (*Uint256) CompareTo

func (u *Uint256) CompareTo(o Uint256) int

func (*Uint256) Deserialize

func (u *Uint256) Deserialize(r io.Reader) error

func (*Uint256) Serialize

func (u *Uint256) Serialize(w io.Writer) (int, error)

func (*Uint256) ToArray

func (u *Uint256) ToArray() []byte

func (*Uint256) ToString

func (u *Uint256) ToString() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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