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 ¶
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.