types

package
v0.0.0-...-ee99c87 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	HeaderHash   common.Hash // Hash on RLP encoded header bytes.
	Header       *BlockHeader
	Transactions []*Transaction
}

Block represents a block in the blockchain.

func NewBlock

func NewBlock(header *BlockHeader, txs []*Transaction) *Block

NewBlock creates a new block. The input header is copied, any change will not affect the block. The input transaction array is copied, but each transaction is not copied. So any change of the input transaction will affect the block.

func (*Block) FindTransaction

func (block *Block) FindTransaction(txHash common.Hash) *Transaction

FindTransaction returns transaction of specified hash if found. Otherwise, returns nil.

type BlockHeader

type BlockHeader struct {
	PreviousBlockHash common.Hash
	Creator           common.Address
	TxHash            common.Hash // Transaction tree root hash
	Difficulty        *big.Int    // Mining difficulty of current block
	Height            *big.Int
	CreateTimestamp   *big.Int
	Nonce             uint64
}

BlockHeader represents the header of a block in the blockchain.

func (*BlockHeader) Clone

func (header *BlockHeader) Clone() *BlockHeader

Clone returns a clone of block header.

type Transaction

type Transaction struct {
	Hash      common.Hash // hash on transaction data
	Data      *TransactionData
	Signature *crypto.Signature
}

Transaction represents a transaction in the blockchain.

func NewTransaction

func NewTransaction(from, to common.Address, amount *big.Int, nonce uint64) *Transaction

NewTransaction creates a new transaction to transfer asset. The transaction data hash is also calculated. Panics if the amount is nil or negative.

func (*Transaction) Sign

func (tx *Transaction) Sign(privKey *ecdsa.PrivateKey)

Sign signs the transaction with private key.

func (*Transaction) Validate

func (tx *Transaction) Validate() error

Validate returns true if the transation is valid, otherwise false.

type TransactionData

type TransactionData struct {
	From         common.Address
	To           *common.Address // nil for contract creation transaction.
	Amount       *big.Int
	AccountNonce uint64
}

TransactionData wraps the data in a transaction.

Jump to

Keyboard shortcuts

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