types

package
v0.0.0-...-7ede18c Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountAddressLength  = 32
	ContractAddressLength = 64
)
View Source
const (
	EKTAddress = ""
	GasAddress = "0000000000000000000000000000000000000000000000000000000000000001"
)
View Source
const (
	EKT_DECIMAL = 8
	GAS_DECIMAL = 0
)

Variables

This section is empty.

Functions

func FromPubKeyToAddress

func FromPubKeyToAddress(pubKey []byte) []byte

Types

type Account

type Account struct {
	Address   HexBytes                   `json:"address"`
	Amount    int64                      `json:"amount"`
	Gas       int64                      `json:"gas"`
	Nonce     int64                      `json:"nonce"`
	Contracts map[string]ContractAccount `json:"contracts"`
	Balances  map[string]int64           `json:"balances"`
}

func NewAccount

func NewAccount(address []byte) *Account

func (*Account) BurnGas

func (account *Account) BurnGas(gas int64)

func (Account) GetAmount

func (account Account) GetAmount() int64

func (Account) GetNonce

func (account Account) GetNonce() int64

func (Account) ToBytes

func (account Account) ToBytes() []byte

func (*Account) Transfer

func (account *Account) Transfer(change AccountChange) bool

type AccountChange

type AccountChange struct {
	M map[string]int64
}

func NewAccountChange

func NewAccountChange() *AccountChange

func (*AccountChange) Add

func (change *AccountChange) Add(tokenAddress string, amount int64)

func (*AccountChange) Reduce

func (change *AccountChange) Reduce(tokenAddress string, amount int64)

type ContractAccount

type ContractAccount struct {
	Address      HexBytes         `json:"address"`
	Amount       int64            `json:"amount"`
	Gas          int64            `json:"gas"`
	CodeHash     HexBytes         `json:"codeHash"`
	ContractData ContractData     `json:"data"`
	Balances     map[string]int64 `json:"balances"`
}

func NewContractAccount

func NewContractAccount(address []byte, contractHash []byte, contractData ContractData) *ContractAccount

func (*ContractAccount) Transfer

func (account *ContractAccount) Transfer(change AccountChange) bool

type ContractData

type ContractData struct {
	Prop     ContractProp `json:"prop"`
	Contract string       `json:"contract"`
}

func (ContractData) Bytes

func (contractData ContractData) Bytes() []byte

func (*ContractData) MarshalJSON

func (contractData *ContractData) MarshalJSON() ([]byte, error)

type ContractProp

type ContractProp struct {
	Name       string `json:"name"`
	Author     string `json:"author"`
	Upgradable bool   `json:"upgradable"`
}

Contract address contains 64 bytes The first 32 byte represents the founders of contract, it is create by system if the first The end 32 byte represents the true address of contract for a founder

func (*ContractProp) MarshalJSON

func (contractProp *ContractProp) MarshalJSON() ([]byte, error)

type HexBytes

type HexBytes []byte

func (HexBytes) MarshalJSON

func (hexBytes HexBytes) MarshalJSON() ([]byte, error)

func (*HexBytes) UnmarshalJSON

func (hexBytes *HexBytes) UnmarshalJSON(data []byte) error

type IVersion

type IVersion interface {
	GetVersion() int64
}

type Peer

type Peer struct {
	Account        string `json:"account"`
	Address        string `json:"address"`
	Port           int32  `json:"port"`
	AddressVersion int    `json:"addressVersion"`
}

func (Peer) Equal

func (peer Peer) Equal(_peer Peer) bool

func (Peer) GetDBValue

func (peer Peer) GetDBValue(key string) ([]byte, error)

func (Peer) IsAlive

func (peer Peer) IsAlive() bool

func (Peer) String

func (peer Peer) String() string

type Peers

type Peers []Peer

func (Peers) Bytes

func (peers Peers) Bytes() []byte

type Round

type Round struct {
	Peers []Peer `json:"peers"`
}

func NewRound

func NewRound(peers Peers) *Round

func (Round) Clone

func (round Round) Clone() Round

func (Round) Distance

func (round Round) Distance(previous, my string) int

func (Round) IndexOf

func (round Round) IndexOf(miner string) int

func (Round) Len

func (round Round) Len() int

type Token

type Token struct {
	Name     string `json:"name"`
	Symbol   string `json:"symbol"`
	Total    int64  `json:"total"`
	Decimals int64  `json:"decimals"`
}

func (Token) Address

func (token Token) Address() []byte

func (Token) Bytes

func (event Token) Bytes() []byte

type Version

type Version map[string]interface{}

func (Version) GetVersion

func (version Version) GetVersion() int64

Jump to

Keyboard shortcuts

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