Documentation ¶
Index ¶
- Variables
- func CalcGasLimit(parent *Block) uint64
- func CreateBloom(receipts Receipts) bloom.Bloom
- func DeriveRootHash(list DerivableList) utils.Hash
- func LogsBloom(logs []*Log) *big.Int
- func NewCandidateTrie(root utils.Hash, db *mtp.Database) (*mtp.Trie, error)
- func NewDelegateTrie(root utils.Hash, db *mtp.Database) (*mtp.Trie, error)
- func NewEpochTrie(root utils.Hash, db *mtp.Database) (*mtp.Trie, error)
- func NewMintCntTrie(root utils.Hash, db *mtp.Database) (*mtp.Trie, error)
- func NewVoteTrie(root utils.Hash, db *mtp.Database) (*mtp.Trie, error)
- type Action
- type Actions
- type Block
- func (b *Block) Action(hash utils.Hash) *Action
- func (b *Block) ActionRoot() utils.Hash
- func (b *Block) Actions() Actions
- func (b *Block) BlockHeader() *BlockHeader
- func (b *Block) Bloom() bloom.Bloom
- func (b *Block) DecodeRLP(s *rlp.Stream) error
- func (b *Block) Difficulty() *big.Int
- func (b *Block) DposCtx() *DposContext
- func (b *Block) EncodeRLP(w io.Writer) error
- func (b *Block) ExtraData() []byte
- func (b *Block) GasLimit() uint64
- func (b *Block) GasUsed() uint64
- func (b *Block) Hash() utils.Hash
- func (b *Block) HashNoNonce() utils.Hash
- func (b *Block) Height() *big.Int
- func (b *Block) Miner() utils.Address
- func (b *Block) Nonce() uint64
- func (b *Block) PreviousHash() utils.Hash
- func (b *Block) ReceiptsRoot() utils.Hash
- func (b *Block) Size() utils.StorageSize
- func (b *Block) StateRoot() utils.Hash
- func (b *Block) Time() *big.Int
- func (b *Block) Transaction(hash utils.Hash) *Transaction
- func (b *Block) Transactions() Transactions
- func (b *Block) TransactionsRoot() utils.Hash
- func (b *Block) WithActions(actions []*Action) *Block
- func (b *Block) WithSeal(header *BlockHeader) *Block
- func (b *Block) WithStateRoot(root utils.Hash) *Block
- func (b *Block) WithTxs(txs []*Transaction) *Block
- type BlockHeader
- type Blocks
- type CandidateInfo
- type Confirmed
- type DerivableList
- type DposContext
- func (d *DposContext) BecomeCandidate(candidateAddr utils.Address) error
- func (d *DposContext) CandidateTrie() *mtp.Trie
- func (d *DposContext) CommitTo(dbw *mtp.Database) (*DposContextProto, error)
- func (d *DposContext) Copy() *DposContext
- func (d *DposContext) DB() *mtp.Database
- func (d *DposContext) Delegate(delegatorAddr utils.Address, candidateAddrs []*utils.Address) error
- func (d *DposContext) DelegateTrie() *mtp.Trie
- func (d *DposContext) EpochTrie() *mtp.Trie
- func (d *DposContext) FromProto(dcp *DposContextProto) error
- func (dc *DposContext) GetCandidateAddrs(delegator utils.Address) ([]utils.Address, error)
- func (dc *DposContext) GetCandidates() ([]*CandidateInfo, error)
- func (dc *DposContext) GetDelegators(candidate utils.Address) ([]utils.Address, error)
- func (dc *DposContext) GetValidators() ([]utils.Address, error)
- func (dc *DposContext) IsDpos() bool
- func (d *DposContext) KickoutCandidate(candidateAddr utils.Address) error
- func (d *DposContext) MintCntTrie() *mtp.Trie
- func (d *DposContext) RevertToSnapShot(snapshot *DposContext)
- func (d *DposContext) Root() (h utils.Hash)
- func (dc *DposContext) SetCandidate(candidate *mtp.Trie)
- func (dc *DposContext) SetDelegate(delegate *mtp.Trie)
- func (dc *DposContext) SetEpoch(epoch *mtp.Trie)
- func (dc *DposContext) SetMintCnt(mintCnt *mtp.Trie)
- func (dc *DposContext) SetValidators(validators []utils.Address) error
- func (dc *DposContext) SetVote(vote *mtp.Trie)
- func (d *DposContext) Snapshot() *DposContext
- func (d *DposContext) ToProto() *DposContextProto
- func (d *DposContext) UnDelegate(delegatorAddr utils.Address) error
- func (d *DposContext) VoteTrie() *mtp.Trie
- type DposContextProto
- type Log
- type LogForStorage
- type Logs
- type MinerNonce
- type Receipt
- type ReceiptForStorage
- type Receipts
- type Signer
- type StorageTx
- type StorageTxs
- type Transaction
- func (tx *Transaction) ChainID(signer Signer) (*big.Int, error)
- func (tx *Transaction) Cost() *big.Int
- func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
- func (tx *Transaction) EncodeRLP(w io.Writer) error
- func (tx *Transaction) Gas() uint64
- func (tx *Transaction) GasPrice() *big.Int
- func (tx *Transaction) Hash() utils.Hash
- func (tx *Transaction) Nonce() uint64
- func (tx *Transaction) Payload() []byte
- func (tx *Transaction) Protected(signer Signer) (bool, error)
- func (tx *Transaction) Sender(signer Signer) (utils.Address, error)
- func (tx *Transaction) SignTx(s Signer, prv *ecdsa.PrivateKey) error
- func (tx *Transaction) Signature() []byte
- func (tx *Transaction) Size() utils.StorageSize
- func (tx *Transaction) Tos() []*utils.Address
- func (tx *Transaction) Type() TxType
- func (tx *Transaction) Validate(cfg *params.ChainConfig) error
- func (tx *Transaction) Value() *big.Int
- func (tx *Transaction) WithSignature(signature []byte)
- type Transactions
- type TransactionsByPriceAndNonce
- type TxType
- type TxsByNonce
- type TxsByPriceToHigh
- type TxsByPriceToLow
Constants ¶
This section is empty.
Variables ¶
var ( // ReceiptStatusFailed is the status code of a transaction if execution failed. ReceiptStatusFailed = uint64(0) // ReceiptStatusFailedRLP is rlp bytes of a transaction if execution failed. ReceiptStatusFailedRLP = []byte{} // ReceiptStatusSuccessful is the status code of a transaction if execution succeeded. ReceiptStatusSuccessful = uint64(1) // ReceiptStatusSuccessfulRLP is rlp bytes of a transaction if execution succeeded. ReceiptStatusSuccessfulRLP = []byte{0x01} )
var ( ErrInvalidSig = errors.New("invalid transaction v, r, s values") ErrInvalidType = errors.New("invalid transaction type") ErrInvalidAddress = errors.New("invalid transaction payload address") ErrInvalidAction = errors.New("invalid transaction payload action") ErrNotFound = errors.New("not found") )
Functions ¶
func CalcGasLimit ¶
CalcGasLimit computes the gas limit of the next block after parent.
func CreateBloom ¶
Types ¶
type Action ¶
type Action struct { TxHash utils.Hash `json:"txHash"` Sender utils.Address `json:"sender"` GenTimeStamp *big.Int `json:"generateTime"` DelayDur *big.Int `json:"delayDuration"` // contains filtered or unexported fields }
Action represents the Redeem transaction deferred Action.
type Actions ¶
type Actions []*Action
Actions .
type Block ¶
type Block struct { // These fields are used to track inter-peer block relay. ReceivedAt time.Time ReceivedFrom interface{} DposContext *DposContext // contains filtered or unexported fields }
Block represents an entire block in the blockchain.
func NewBlock ¶
func NewBlock(header *BlockHeader, txs []*Transaction, actions []*Action, receipts []*Receipt) *Block
NewBlock creates a new block.
func NewBlockWithBlockHeader ¶
func NewBlockWithBlockHeader(header *BlockHeader) *Block
NewBlockWithBlockHeader creates a block with the given header data.
func (*Block) ActionRoot ¶
func (*Block) BlockHeader ¶
func (b *Block) BlockHeader() *BlockHeader
func (*Block) Difficulty ¶
func (*Block) DposCtx ¶
func (b *Block) DposCtx() *DposContext
func (*Block) PreviousHash ¶
func (*Block) ReceiptsRoot ¶
func (*Block) Size ¶
func (b *Block) Size() utils.StorageSize
Size returns the true RLP encoded storage size of the block
func (*Block) Transaction ¶
func (b *Block) Transaction(hash utils.Hash) *Transaction
func (*Block) Transactions ¶
func (b *Block) Transactions() Transactions
func (*Block) TransactionsRoot ¶
func (*Block) WithActions ¶
WithActions a block with the given actions data.
func (*Block) WithSeal ¶
func (b *Block) WithSeal(header *BlockHeader) *Block
WithSeal returns a new block with the data from b but the header replaced with the sealed one.
func (*Block) WithStateRoot ¶
WithStateRoot a block with the given state root.
func (*Block) WithTxs ¶
func (b *Block) WithTxs(txs []*Transaction) *Block
WithTxs a block with the given txs data.
type BlockHeader ¶
type BlockHeader struct { PreviousHash utils.Hash `json:"previousHash"` Miner utils.Address `json:"miner"` StateRoot utils.Hash `json:"stateRoot"` ActionsRoot utils.Hash `json:"actonsroot"` TransactionsRoot utils.Hash `json:"transactionsRoot"` ReceiptsRoot utils.Hash `json:"receiptsRoot"` DposContext *DposContextProto `json:"dposContext" rlp:"nil"` LogsBloom bloom.Bloom `json:"logsBloom"` Difficulty *big.Int `json:"difficulty"` Height *big.Int `json:"height"` GasLimit uint64 `json:"gasLimit"` GasUsed uint64 `json:"gasUsed" ` TimeStamp *big.Int `json:"timestamp"` ExtraData []byte `json:"extraData"` Nonce MinerNonce `json:"nonce"` }
BlockHeader represents a block header in blockchain.
func CopyBlockHeader ¶
func CopyBlockHeader(h *BlockHeader) *BlockHeader
CopyBlockHeader creates a deep copy of a block header
func (*BlockHeader) Hash ¶
func (h *BlockHeader) Hash() utils.Hash
Hash returns the block hash of the header
func (*BlockHeader) HashNoNonce ¶
func (h *BlockHeader) HashNoNonce() utils.Hash
HashNoNonce returns the hash which is used as input for the proof-of-work search.
func (*BlockHeader) Size ¶
func (h *BlockHeader) Size() utils.StorageSize
Size returns the approximate memory used by all internal contents.
type CandidateInfo ¶
type Confirmed ¶
type Confirmed struct { BlockHeight uint64 // confirmed BlockHash utils.Hash // confirmed Address utils.Address // producer Signature []byte // signature }
func (*Confirmed) IsValidate ¶
IsValidate returns the validate
type DerivableList ¶
DerivableList array
type DposContext ¶
type DposContext struct {
// contains filtered or unexported fields
}
func NewDposContext ¶
func NewDposContext(db *mtp.Database) (*DposContext, error)
func NewDposContextFromProto ¶
func NewDposContextFromProto(db *mtp.Database, ctxProto *DposContextProto) (*DposContext, error)
func (*DposContext) BecomeCandidate ¶
func (d *DposContext) BecomeCandidate(candidateAddr utils.Address) error
func (*DposContext) CandidateTrie ¶
func (d *DposContext) CandidateTrie() *mtp.Trie
func (*DposContext) CommitTo ¶
func (d *DposContext) CommitTo(dbw *mtp.Database) (*DposContextProto, error)
func (*DposContext) Copy ¶
func (d *DposContext) Copy() *DposContext
func (*DposContext) DB ¶
func (d *DposContext) DB() *mtp.Database
func (*DposContext) DelegateTrie ¶
func (d *DposContext) DelegateTrie() *mtp.Trie
func (*DposContext) EpochTrie ¶
func (d *DposContext) EpochTrie() *mtp.Trie
func (*DposContext) FromProto ¶
func (d *DposContext) FromProto(dcp *DposContextProto) error
func (*DposContext) GetCandidateAddrs ¶
func (*DposContext) GetCandidates ¶
func (dc *DposContext) GetCandidates() ([]*CandidateInfo, error)
func (*DposContext) GetDelegators ¶
func (*DposContext) GetValidators ¶
func (dc *DposContext) GetValidators() ([]utils.Address, error)
func (*DposContext) IsDpos ¶
func (dc *DposContext) IsDpos() bool
func (*DposContext) KickoutCandidate ¶
func (d *DposContext) KickoutCandidate(candidateAddr utils.Address) error
func (*DposContext) MintCntTrie ¶
func (d *DposContext) MintCntTrie() *mtp.Trie
func (*DposContext) RevertToSnapShot ¶
func (d *DposContext) RevertToSnapShot(snapshot *DposContext)
func (*DposContext) Root ¶
func (d *DposContext) Root() (h utils.Hash)
func (*DposContext) SetCandidate ¶
func (dc *DposContext) SetCandidate(candidate *mtp.Trie)
func (*DposContext) SetDelegate ¶
func (dc *DposContext) SetDelegate(delegate *mtp.Trie)
func (*DposContext) SetEpoch ¶
func (dc *DposContext) SetEpoch(epoch *mtp.Trie)
func (*DposContext) SetMintCnt ¶
func (dc *DposContext) SetMintCnt(mintCnt *mtp.Trie)
func (*DposContext) SetValidators ¶
func (dc *DposContext) SetValidators(validators []utils.Address) error
func (*DposContext) SetVote ¶
func (dc *DposContext) SetVote(vote *mtp.Trie)
func (*DposContext) Snapshot ¶
func (d *DposContext) Snapshot() *DposContext
func (*DposContext) ToProto ¶
func (d *DposContext) ToProto() *DposContextProto
func (*DposContext) UnDelegate ¶
func (d *DposContext) UnDelegate(delegatorAddr utils.Address) error
func (*DposContext) VoteTrie ¶
func (d *DposContext) VoteTrie() *mtp.Trie
type DposContextProto ¶
type DposContextProto struct { EpochHash utils.Hash `json:"epochRoot" gencodec:"required"` DelegateHash utils.Hash `json:"delegateRoot" gencodec:"required"` CandidateHash utils.Hash `json:"candidateRoot" gencodec:"required"` VoteHash utils.Hash `json:"voteRoot" gencodec:"required"` MintCntHash utils.Hash `json:"mintCntRoot" gencodec:"required"` }
func (*DposContextProto) Root ¶
func (p *DposContextProto) Root() (h utils.Hash)
type Log ¶
type Log struct { // Consensus fields: Address utils.Address `json:"address" gencodec:"required"` // address of the contract that generated the event Topics []utils.Hash `json:"topics" gencodec:"required"` // list of topics provided by the contract. Data []byte `json:"data" gencodec:"required"` // supplied by the contract, usually ABI-encoded // Derived fields. These fields are filled in by the node but not secured by consensus. BlockHeight uint64 `json:"blockHeight"` // block in which the transaction was included BlockHash utils.Hash `json:"blockHash"` // hash of the block in which the transaction was included TransactionHash utils.Hash `json:"transactionHash" gencodec:"required"` // hash of the transaction TransactionIndex uint `json:"transactionIndex" gencodec:"required"` // index of the transaction in the block LogIndex uint `json:"logIndex" gencodec:"required"` // index of the log in the receipt Removed bool `json:"removed"` // The Removed field is true if this log was reverted due to a chain reorganisation. }
Log represents a contract log event. These events are generated by the log opcode and stored/indexed by the node.
type LogForStorage ¶
type LogForStorage Log
LogForStorage is a wrapper around a Log that flattens and parses the entire content of a log including non-consensus fields.
type Logs ¶
type Logs []*Log
Logs is a wrapper around a Log array to implement DerivableList.
type MinerNonce ¶
type MinerNonce [8]byte
A MinerNonce is a 64-bit hash which proves (combined with the mix-hash) that a sufficient amount of computation has been carried out on a block.
func EncodeNonce ¶
func EncodeNonce(i uint64) MinerNonce
EncodeNonce converts the given integer to a block nonce.
func (MinerNonce) MarshalText ¶
func (n MinerNonce) MarshalText() ([]byte, error)
MarshalText encodes n as a hex string with 0x prefix.
func (MinerNonce) Uint64 ¶
func (n MinerNonce) Uint64() uint64
Uint64 returns the integer value of a block nonce.
func (*MinerNonce) UnmarshalText ¶
func (n *MinerNonce) UnmarshalText(input []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type Receipt ¶
type Receipt struct { // Consensus fields State []byte `json:"root"` Status uint64 `json:"status"` CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"` LogsBloom bloom.Bloom `json:"logsBloom" gencodec:"required"` Logs []*Log `json:"logs" gencodec:"required"` // Derived fields. (don't reorder!) TransactionHash utils.Hash `json:"transactionHash" gencodec:"required"` ContractAddress utils.Address `json:"contractAddress"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` }
Receipt represents the results of a transaction.
func NewReceipt ¶
NewReceipt creates a transaction receipt.
func (*Receipt) Size ¶
func (r *Receipt) Size() utils.StorageSize
Size returns the approximate memory used by all internal contents.
type ReceiptForStorage ¶
type ReceiptForStorage Receipt
ReceiptForStorage is a wrapper around a Receipt that flattens and parses the entire content of a log including non-consensus fields.
type Receipts ¶
type Receipts []*Receipt
Receipts is a wrapper around a Receipt array to implement DerivableList.
type Signer ¶
type Signer struct{}
Signer encapsulates transaction signature handling.
type StorageTx ¶
type StorageTx struct { BlockHash utils.Hash BlockHeight uint64 TxIndex uint64 Tx *Transaction }
func NewStorageTx ¶
func NewStorageTx(blockHash utils.Hash, blockHeight, txIndex uint64, tx *Transaction) *StorageTx
type StorageTxs ¶
type StorageTxs []*StorageTx
func (StorageTxs) ToTransactions ¶
func (s StorageTxs) ToTransactions() Transactions
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction transaction
func NewTransaction ¶
func NewTransaction(txType TxType, nonce uint64, value *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, tos ...*utils.Address) *Transaction
NewTransaction new transaction
func (*Transaction) ChainID ¶
func (tx *Transaction) ChainID(signer Signer) (*big.Int, error)
ChainID returns which chain id this transaction was signed for (if at all)
func (*Transaction) Cost ¶
func (tx *Transaction) Cost() *big.Int
Cost returns value + gasprice * gaslimit.
func (*Transaction) DecodeRLP ¶
func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder
func (*Transaction) EncodeRLP ¶
func (tx *Transaction) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder
func (*Transaction) Gas ¶
func (tx *Transaction) Gas() uint64
func (*Transaction) GasPrice ¶
func (tx *Transaction) GasPrice() *big.Int
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() utils.Hash
Hash hashes the RLP encoding of tx. It uniquely identifies the transaction.
func (*Transaction) Nonce ¶
func (tx *Transaction) Nonce() uint64
func (*Transaction) Payload ¶
func (tx *Transaction) Payload() []byte
func (*Transaction) Protected ¶
func (tx *Transaction) Protected(signer Signer) (bool, error)
Protected returns whether the transaction is protected from replay protection.
func (*Transaction) Sender ¶
func (tx *Transaction) Sender(signer Signer) (utils.Address, error)
Sender sender address of the transaction using the given signer
func (*Transaction) SignTx ¶
func (tx *Transaction) SignTx(s Signer, prv *ecdsa.PrivateKey) error
SignTx signs the transaction using the given signer and private key
func (*Transaction) Signature ¶
func (tx *Transaction) Signature() []byte
func (*Transaction) Size ¶
func (tx *Transaction) Size() utils.StorageSize
Size returns the true RLP encoded storage size of the transaction
func (*Transaction) Tos ¶
func (tx *Transaction) Tos() []*utils.Address
func (*Transaction) Type ¶
func (tx *Transaction) Type() TxType
func (*Transaction) Validate ¶
func (tx *Transaction) Validate(cfg *params.ChainConfig) error
Validate Valid the transaction when the type isn't the binary
func (*Transaction) Value ¶
func (tx *Transaction) Value() *big.Int
func (*Transaction) WithSignature ¶
func (tx *Transaction) WithSignature(signature []byte)
WithSignature returns a new transaction with the given signature.
type Transactions ¶
type Transactions []*Transaction
Transactions is is a wrapper around a Transaction array to implement DerivableList.
func (Transactions) GetRlp ¶
func (s Transactions) GetRlp(i int) []byte
GetRlp implements Rlpable and returns the i'th element of s in rlp.
type TransactionsByPriceAndNonce ¶
type TransactionsByPriceAndNonce struct {
// contains filtered or unexported fields
}
TransactionsByPriceAndNonce represents a set of transactions
func NewTransactionsByPriceAndNonce ¶
func NewTransactionsByPriceAndNonce(signer Signer, txs map[utils.Address]Transactions) *TransactionsByPriceAndNonce
NewTransactionsByPriceAndNonce creates a transaction set that can retrieve price sorted transactions in a nonce-honouring way.
func (*TransactionsByPriceAndNonce) Peek ¶
func (t *TransactionsByPriceAndNonce) Peek() *Transaction
Peek returns the next transaction by price.
func (*TransactionsByPriceAndNonce) Pop ¶
func (t *TransactionsByPriceAndNonce) Pop()
Pop removes the best transactiont.
func (*TransactionsByPriceAndNonce) Shift ¶
func (t *TransactionsByPriceAndNonce) Shift()
Shift replaces the current best head with the next one from the same account.
type TxsByNonce ¶
type TxsByNonce Transactions
TxsByNonce transactions sort by nonce
func (TxsByNonce) Len ¶
func (s TxsByNonce) Len() int
func (TxsByNonce) Less ¶
func (s TxsByNonce) Less(i, j int) bool
func (TxsByNonce) Swap ¶
func (s TxsByNonce) Swap(i, j int)
type TxsByPriceToHigh ¶
type TxsByPriceToHigh []*Transaction
TxsByPriceToHigh Price from low to high
func (TxsByPriceToHigh) Len ¶
func (t TxsByPriceToHigh) Len() int
func (TxsByPriceToHigh) Less ¶
func (t TxsByPriceToHigh) Less(i, j int) bool
func (TxsByPriceToHigh) Swap ¶
func (t TxsByPriceToHigh) Swap(i, j int)
type TxsByPriceToLow ¶
type TxsByPriceToLow Transactions
TxsByPriceToLow transactions sort by price and implements the heap interface Price from high to low
func (TxsByPriceToLow) Len ¶
func (s TxsByPriceToLow) Len() int
func (TxsByPriceToLow) Less ¶
func (s TxsByPriceToLow) Less(i, j int) bool
func (*TxsByPriceToLow) Pop ¶
func (s *TxsByPriceToLow) Pop() interface{}
func (*TxsByPriceToLow) Push ¶
func (s *TxsByPriceToLow) Push(x interface{})
func (TxsByPriceToLow) Swap ¶
func (s TxsByPriceToLow) Swap(i, j int)