Documentation ¶
Index ¶
- type Block
- func (b *Block) CalculateGasUsage() int64
- func (b *Block) CalculateHeadHash() error
- func (b *Block) CalculateTxMerkleHash() []byte
- func (b *Block) CalculateTxReceiptMerkleHash() []byte
- func (b *Block) Decode(blockByte []byte) error
- func (b *Block) Encode() ([]byte, error)
- func (b *Block) EncodeM() ([]byte, error)
- func (b *Block) HeadHash() []byte
- func (b *Block) LenTx() int
- type BlockChain
- func (bc *BlockChain) AllDelaytx() ([]*tx.Tx, error)
- func (bc *BlockChain) CheckLength()
- func (bc *BlockChain) Close()
- func (bc *BlockChain) Draw(start int64, end int64) string
- func (bc *BlockChain) GetBlockByHash(hash []byte) (*Block, error)
- func (bc *BlockChain) GetBlockByNumber(number int64) (*Block, error)
- func (bc *BlockChain) GetHashByNumber(number int64) ([]byte, error)
- func (bc *BlockChain) GetReceipt(hash []byte) (*tx.TxReceipt, error)
- func (bc *BlockChain) GetReceiptByTxHash(hash []byte) (*tx.TxReceipt, error)
- func (bc *BlockChain) GetTx(hash []byte) (*tx.Tx, error)
- func (bc *BlockChain) HasReceipt(hash []byte) (bool, error)
- func (bc *BlockChain) HasTx(hash []byte) (bool, error)
- func (bc *BlockChain) Length() int64
- func (bc *BlockChain) Push(block *Block) error
- func (bc *BlockChain) SetLength(i int64)
- func (bc *BlockChain) SetTxTotal(i int64)
- func (bc *BlockChain) Size() (int64, error)
- func (bc *BlockChain) Top() (*Block, error)
- func (bc *BlockChain) TxTotal() int64
- type BlockHead
- type Chain
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { Head *BlockHead Sign *crypto.Signature Txs []*tx.Tx Receipts []*tx.TxReceipt TxHashes [][]byte ReceiptHashes [][]byte // contains filtered or unexported fields }
Block is the implementation of block
func (*Block) CalculateGasUsage ¶ added in v1.1.0
CalculateGasUsage calculates the block's gas usage.
func (*Block) CalculateHeadHash ¶
CalculateHeadHash calculate the hash of the head
func (*Block) CalculateTxMerkleHash ¶ added in v1.1.0
CalculateTxMerkleHash calculate the merkle hash of the transaction.
func (*Block) CalculateTxReceiptMerkleHash ¶ added in v1.1.0
CalculateTxReceiptMerkleHash calculate the merkle hash of the transaction receipt.
type BlockChain ¶
type BlockChain struct {
// contains filtered or unexported fields
}
BlockChain is the implementation of chain
func (*BlockChain) AllDelaytx ¶ added in v1.1.0
func (bc *BlockChain) AllDelaytx() ([]*tx.Tx, error)
AllDelaytx returns all delay transactions.
func (*BlockChain) CheckLength ¶
func (bc *BlockChain) CheckLength()
CheckLength is check length of block in database
func (*BlockChain) Draw ¶
func (bc *BlockChain) Draw(start int64, end int64) string
Draw the graph about blockchain
func (*BlockChain) GetBlockByHash ¶
func (bc *BlockChain) GetBlockByHash(hash []byte) (*Block, error)
GetBlockByHash is get block by hash
func (*BlockChain) GetBlockByNumber ¶
func (bc *BlockChain) GetBlockByNumber(number int64) (*Block, error)
GetBlockByNumber is get block by number
func (*BlockChain) GetHashByNumber ¶
func (bc *BlockChain) GetHashByNumber(number int64) ([]byte, error)
GetHashByNumber is get hash by number
func (*BlockChain) GetReceipt ¶ added in v1.1.0
func (bc *BlockChain) GetReceipt(hash []byte) (*tx.TxReceipt, error)
GetReceipt gets receipt with receipt's hash
func (*BlockChain) GetReceiptByTxHash ¶ added in v1.1.0
func (bc *BlockChain) GetReceiptByTxHash(hash []byte) (*tx.TxReceipt, error)
GetReceiptByTxHash gets receipt with tx's hash
func (*BlockChain) GetTx ¶ added in v1.1.0
func (bc *BlockChain) GetTx(hash []byte) (*tx.Tx, error)
GetTx gets tx with tx's hash.
func (*BlockChain) HasReceipt ¶ added in v1.1.0
func (bc *BlockChain) HasReceipt(hash []byte) (bool, error)
HasReceipt checks if database has receipt.
func (*BlockChain) HasTx ¶ added in v1.1.0
func (bc *BlockChain) HasTx(hash []byte) (bool, error)
HasTx checks if database has tx.
func (*BlockChain) Length ¶
func (bc *BlockChain) Length() int64
Length return length of block chain
func (*BlockChain) Push ¶
func (bc *BlockChain) Push(block *Block) error
Push save the block to database
func (*BlockChain) SetLength ¶ added in v1.1.0
func (bc *BlockChain) SetLength(i int64)
SetLength sets blockchain's length.
func (*BlockChain) SetTxTotal ¶
func (bc *BlockChain) SetTxTotal(i int64)
SetTxTotal sets blockchain's tx total.
func (*BlockChain) Size ¶
func (bc *BlockChain) Size() (int64, error)
Size returns the blockchain db size
func (*BlockChain) TxTotal ¶
func (bc *BlockChain) TxTotal() int64
TxTotal return tx total of block chain
type BlockHead ¶
type BlockHead struct { Version int64 ParentHash []byte TxMerkleHash []byte TxReceiptMerkleHash []byte Info []byte Number int64 Witness string Time int64 GasUsage int64 }
BlockHead is the struct of block head.
type Chain ¶
type Chain interface { Push(block *Block) error Length() int64 TxTotal() int64 CheckLength() Top() (*Block, error) GetHashByNumber(number int64) ([]byte, error) GetBlockByNumber(number int64) (*Block, error) GetBlockByHash(blockHash []byte) (*Block, error) GetTx(hash []byte) (*tx.Tx, error) HasTx(hash []byte) (bool, error) GetReceipt(Hash []byte) (*tx.TxReceipt, error) GetReceiptByTxHash(Hash []byte) (*tx.TxReceipt, error) HasReceipt(hash []byte) (bool, error) Size() (int64, error) Close() AllDelaytx() ([]*tx.Tx, error) Draw(int64, int64) string }
Chain defines Chain's API.
func NewBlockChain ¶
NewBlockChain returns a Chain instance