types

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeAtomic          uint32 = iota // 链内交易
	TypeAcrossChain                   // 跨链交易
	TypeMerged                        // 跨链合并交易
	TypeBackfront                     // 资金回笼交易
	TypeDistribut                     // 下发交易
	TypeIssue                         // 发行交易
	TypeJSContractInit                // js contract_Init
	TypeLuaContractInit               // lua contract_Init
	TypeContractInvoke                // contract_Invoke
	TypeContractQuery                 // contract_Query
)

Transaction type

Variables

View Source
var (
	// ErrEmptySignature represents no signature
	ErrEmptySignature = errors.New("Signature Empty Error")
)

Functions

func SerializeTxs

func SerializeTxs(r io.Writer, txs Transactions)

SerializeTxs serializes transactions

Types

type Block

type Block struct {
	Header       *BlockHeader `json:"header"`
	Transactions Transactions `json:"transactions"`
	// contains filtered or unexported fields
}

Block represents an block in blockchain

func NewBlock

func NewBlock(prvHash crypto.Hash,
	timeStamp, height, nonce uint32,
	txsHash crypto.Hash,
	Txs Transactions) *Block

NewBlock returns an new block

func (*Block) Deserialize

func (b *Block) Deserialize(data []byte) error

Deserialize deserializes bytes to Block

func (*Block) GetTransactions

func (b *Block) GetTransactions(transactionType uint32) (Transactions, error)

GetTransactions get Transactions by Type

func (*Block) Hash

func (b *Block) Hash() crypto.Hash

Hash returns the hash of the blockheader in block

func (*Block) Height

func (b *Block) Height() uint32

Height returns the block height

func (*Block) PreviousHash

func (b *Block) PreviousHash() crypto.Hash

PreviousHash returns the previous hash of the block

func (*Block) Serialize

func (b *Block) Serialize() []byte

Serialize serializes the all data in block

type BlockHeader

type BlockHeader struct {
	PreviousHash  crypto.Hash `json:"previousHash" `
	TimeStamp     uint32      `json:"timeStamp"`
	Nonce         uint32      `json:"nonce" `
	TxsMerkleHash crypto.Hash `json:"transactionsMerkleHash" `
	Height        uint32      `json:"height" `
}

BlockHeader represents the header in block

func NewBlockHeader

func NewBlockHeader(prvHash crypto.Hash, timeStamp, height, nonce uint32, txsHash crypto.Hash) *BlockHeader

NewBlockHeader returns a blockheader

func (*BlockHeader) Deserialize

func (h *BlockHeader) Deserialize(data []byte) error

Deserialize deserialize the input data to header

func (*BlockHeader) Hash

func (h *BlockHeader) Hash() crypto.Hash

Hash returns the hash of the blockheader

func (BlockHeader) Serialize

func (h BlockHeader) Serialize() []byte

Serialize returns the serialized bytes of a blockheader

type ContractSpec

type ContractSpec struct {
	ContractAddr   []byte
	ContractCode   []byte
	ContractParams []string
}

type IInventory

type IInventory interface {
	Hash() crypto.Hash
	Serialize() []byte
}

IInventory defines interface that broadcast data should implements

type Transaction

type Transaction struct {
	Data    txdata `json:"data"`
	Payload []byte `json:"payload"`
	// contains filtered or unexported fields
}

Transaction represents the basic transaction that contained in blocks

func NewTransaction

func NewTransaction(
	fromChain coordinate.ChainCoordinate,
	toChain coordinate.ChainCoordinate,
	txType uint32, nonce uint32, sender, reciepent accounts.Address,
	amount, fee *big.Int, CreateTime uint32) *Transaction

NewTransaction creates an new transaction with the parameters

func (*Transaction) Amount

func (tx *Transaction) Amount() *big.Int

Amount returns the transfer �amount of the transaction

func (*Transaction) Compare

func (tx *Transaction) Compare(v interface{}) int

Compare implements interface consensus need

func (*Transaction) CreateTime

func (tx *Transaction) CreateTime() uint32

CreateTime returns the create time of the transaction

func (*Transaction) Deserialize

func (tx *Transaction) Deserialize(data []byte) error

Deserialize deserializes bytes to a transaction

func (*Transaction) Fee

func (tx *Transaction) Fee() *big.Int

Fee returns the nonce of the transaction

func (*Transaction) FromChain

func (tx *Transaction) FromChain() string

FromChain returns the chain coordinate of the sender

func (*Transaction) GetType

func (tx *Transaction) GetType() uint32

GetType returns transaction type

func (*Transaction) Hash

func (tx *Transaction) Hash() crypto.Hash

Hash returns the hash of a transaction

func (*Transaction) IsLocalChain

func (tx *Transaction) IsLocalChain() bool

IsLocalChain returns whether or not local chain

func (*Transaction) Nonce

func (tx *Transaction) Nonce() uint32

Nonce returns the nonce of the transaction

func (*Transaction) Recipient

func (tx *Transaction) Recipient() accounts.Address

Recipient returns the address of the recipient

func (*Transaction) Sender

func (tx *Transaction) Sender() accounts.Address

Sender returns the address of the sender.

func (*Transaction) Serialize

func (tx *Transaction) Serialize() []byte

Serialize returns the serialized bytes of a transaction

func (*Transaction) SignHash

func (tx *Transaction) SignHash() crypto.Hash

SignHash returns the hash of a raw transaction before sign

func (*Transaction) ToChain

func (tx *Transaction) ToChain() string

ToChain returns the chain coordinate of the recipient

func (*Transaction) Verfiy

func (tx *Transaction) Verfiy() (accounts.Address, error)

Verfiy Also can use this method verify signature

func (*Transaction) WithPayload

func (tx *Transaction) WithPayload(data []byte)

WithPayload returns a new transaction with the given data

func (*Transaction) WithSignature

func (tx *Transaction) WithSignature(sig *crypto.Signature)

WithSignature returns a new transaction with the given signature.

type Transactions

type Transactions []*Transaction

Transactions represents transaction slice type for basic sorting.

func DeserializeTxs

func DeserializeTxs(r io.Reader) Transactions

DeserializeTxs deserializes transactions

func (Transactions) Len

func (s Transactions) Len() int

Len returns the length of s

func (Transactions) Less

func (s Transactions) Less(i, j int) bool

Less compares nonce of the i'th and the j'th element in s

func (Transactions) Swap

func (s Transactions) Swap(i, j int)

Swap swaps the i'th and the j'th element in s

Jump to

Keyboard shortcuts

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