Documentation
¶
Overview ¶
Modified from go-ethereum under GNU Lesser General Public License
Index ¶
- Constants
- Variables
- func BloomLookup(bin Bloom, topic bytesBacked) bool
- func CalculateMerkleRoot(list interface{}) (h common.Hash)
- func DeriveSha(list DerivableList) common.Hash
- func LogsBloom(logs []*Log) *big.Int
- func Sender(signer Signer, tx *EvmTransaction) (account.Recipient, error)
- type Bloom
- func (b *Bloom) Add(d *big.Int)
- func (b Bloom) Big() *big.Int
- func (b Bloom) Bytes() []byte
- func (b Bloom) MarshalText() ([]byte, error)
- func (b *Bloom) SetBytes(d []byte)
- func (b Bloom) Test(test *big.Int) bool
- func (b Bloom) TestBytes(test []byte) bool
- func (b *Bloom) UnmarshalText(input []byte) error
- type ChainMask
- type CrossShardTransactionDeposit
- type CrossShardTransactionDepositList
- type DerivableList
- type EIP155Signer
- type EvmTransaction
- func NewEvmContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, ...) *EvmTransaction
- func NewEvmTransaction(nonce uint64, to account.Recipient, amount *big.Int, gasLimit uint64, ...) *EvmTransaction
- func SignTx(tx *EvmTransaction, s Signer, prv *ecdsa.PrivateKey) (*EvmTransaction, error)
- func (tx *EvmTransaction) AsMessage(s Signer) (Message, error)
- func (tx *EvmTransaction) CheckNonce() bool
- func (tx *EvmTransaction) Cost() *big.Int
- func (tx *EvmTransaction) Data() []byte
- func (tx *EvmTransaction) DecodeRLP(s *rlp.Stream) error
- func (tx *EvmTransaction) EncodeRLP(w io.Writer) error
- func (tx *EvmTransaction) FromChainID() uint32
- func (tx *EvmTransaction) FromFullShardId() uint32
- func (tx *EvmTransaction) FromFullShardKey() uint32
- func (tx *EvmTransaction) FromShardID() uint32
- func (tx *EvmTransaction) FromShardSize() uint32
- func (tx *EvmTransaction) Gas() uint64
- func (tx *EvmTransaction) GasPrice() *big.Int
- func (tx *EvmTransaction) Hash() common.Hash
- func (tx *EvmTransaction) IsCrossShard() bool
- func (tx *EvmTransaction) NetworkId() uint32
- func (tx *EvmTransaction) Nonce() uint64
- func (tx *EvmTransaction) RawSignatureValues() (*big.Int, *big.Int, *big.Int)
- func (tx *EvmTransaction) SetFromShardSize(shardSize uint32) error
- func (e *EvmTransaction) SetGas(data uint64)
- func (e *EvmTransaction) SetNonce(data uint64)
- func (tx *EvmTransaction) SetToShardSize(shardSize uint32) error
- func (e *EvmTransaction) SetVRS(v, r, s *big.Int)
- func (tx *EvmTransaction) Size() common.StorageSize
- func (tx *EvmTransaction) To() *account.Recipient
- func (tx *EvmTransaction) ToChainID() uint32
- func (tx *EvmTransaction) ToFullShardId() uint32
- func (tx *EvmTransaction) ToFullShardKey() uint32
- func (tx *EvmTransaction) ToShardID() uint32
- func (tx *EvmTransaction) ToShardSize() uint32
- func (tx *EvmTransaction) Value() *big.Int
- func (tx *EvmTransaction) Version() uint32
- func (tx *EvmTransaction) WithSignature(signer Signer, sig []byte) (*EvmTransaction, error)
- type IBlock
- type IHashable
- type IHeader
- type Log
- type LogForStorage
- type Message
- func (m Message) CheckNonce() bool
- func (m Message) Data() []byte
- func (m Message) From() common.Address
- func (m Message) FromFullShardKey() uint32
- func (m Message) Gas() uint64
- func (m Message) GasPrice() *big.Int
- func (m Message) IsCrossShard() bool
- func (m Message) Nonce() uint64
- func (m Message) To() *common.Address
- func (m Message) ToFullShardKey() uint32
- func (m Message) TxHash() common.Hash
- func (m Message) Value() *big.Int
- type MinorBlock
- func (h *MinorBlock) AddTx(tx *Transaction)
- func (b *MinorBlock) Bloom() Bloom
- func (b *MinorBlock) Branch() account.Branch
- func (b *MinorBlock) Coinbase() account.Address
- func (b *MinorBlock) CoinbaseAmount() *big.Int
- func (b *MinorBlock) Content() []IHashable
- func (h *MinorBlock) CreateBlockToAppend(createTime *uint64, difficulty *big.Int, address *account.Address, ...) *MinorBlock
- func (b *MinorBlock) CrossShardGasUsed() *big.Int
- func (b *MinorBlock) Deserialize(bb *serialize.ByteBuffer) error
- func (b *MinorBlock) Difficulty() *big.Int
- func (b *MinorBlock) Extra() []byte
- func (m *MinorBlock) Finalize(receipts Receipts, rootHash common.Hash, gasUsed *big.Int, ...)
- func (b *MinorBlock) GasLimit() *big.Int
- func (b *MinorBlock) GasUsed() *big.Int
- func (b *MinorBlock) GetMetaData() *MinorBlockMeta
- func (b *MinorBlock) GetSize() common.StorageSize
- func (b *MinorBlock) GetTrackingData() []byte
- func (b *MinorBlock) GetTransactions() Transactions
- func (b *MinorBlock) Hash() common.Hash
- func (b *MinorBlock) Header() *MinorBlockHeader
- func (b *MinorBlock) IHeader() IHeader
- func (b *MinorBlock) Meta() *MinorBlockMeta
- func (b *MinorBlock) MetaHash() common.Hash
- func (b *MinorBlock) MixDigest() common.Hash
- func (b *MinorBlock) Nonce() uint64
- func (b *MinorBlock) Number() uint64
- func (b *MinorBlock) NumberU64() uint64
- func (b *MinorBlock) ParentHash() common.Hash
- func (b *MinorBlock) PrevRootBlockHash() common.Hash
- func (b *MinorBlock) ReceiptHash() common.Hash
- func (b *MinorBlock) Root() common.Hash
- func (b *MinorBlock) Serialize(w *[]byte) error
- func (b *MinorBlock) Size() common.StorageSize
- func (b *MinorBlock) Time() uint64
- func (b *MinorBlock) TrackingData() []byte
- func (b *MinorBlock) Transaction(hash common.Hash) *Transaction
- func (b *MinorBlock) Transactions() Transactions
- func (b *MinorBlock) TxHash() common.Hash
- func (b *MinorBlock) Version() uint32
- func (b *MinorBlock) WithBody(transactions []*Transaction, trackingData []byte) *MinorBlock
- func (b *MinorBlock) WithMingResult(nonce uint64, mixDigest common.Hash) IBlock
- func (b *MinorBlock) WithSeal(header *MinorBlockHeader) *MinorBlock
- type MinorBlockHeader
- func (h *MinorBlockHeader) GetBloom() Bloom
- func (h *MinorBlockHeader) GetBranch() account.Branch
- func (h *MinorBlockHeader) GetCoinbase() account.Address
- func (h *MinorBlockHeader) GetCoinbaseAmount() *big.Int
- func (h *MinorBlockHeader) GetDifficulty() *big.Int
- func (h *MinorBlockHeader) GetExtra() []byte
- func (h *MinorBlockHeader) GetGasLimit() *big.Int
- func (h *MinorBlockHeader) GetMetaHash() common.Hash
- func (h *MinorBlockHeader) GetMixDigest() common.Hash
- func (h *MinorBlockHeader) GetNonce() uint64
- func (h *MinorBlockHeader) GetParentHash() common.Hash
- func (h *MinorBlockHeader) GetPrevRootBlockHash() common.Hash
- func (h *MinorBlockHeader) GetTime() uint64
- func (h *MinorBlockHeader) GetTotalDifficulty() *big.Int
- func (h *MinorBlockHeader) Hash() common.Hash
- func (h *MinorBlockHeader) NumberU64() uint64
- func (h *MinorBlockHeader) SealHash() common.Hash
- func (h *MinorBlockHeader) SetCoinbase(addr account.Address)
- func (h *MinorBlockHeader) SetDifficulty(difficulty *big.Int)
- func (h *MinorBlockHeader) SetExtra(data []byte)
- func (h *MinorBlockHeader) SetNonce(nonce uint64)
- func (h *MinorBlockHeader) Size() common.StorageSize
- type MinorBlockHeaders
- type MinorBlockMeta
- type Receipt
- type ReceiptForStorage
- type Receipts
- type RootBlock
- func (b *RootBlock) AddMinorBlockHeader(header *MinorBlockHeader)
- func (b *RootBlock) Coinbase() account.Address
- func (b *RootBlock) CoinbaseAmount() *big.Int
- func (b *RootBlock) Content() []IHashable
- func (b *RootBlock) Deserialize(bb *serialize.ByteBuffer) error
- func (b *RootBlock) Difficulty() *big.Int
- func (b *RootBlock) ExtendMinorBlockHeaderList(headers []*MinorBlockHeader)
- func (b *RootBlock) Extra() []byte
- func (b *RootBlock) Finalize(coinbaseAmount *big.Int, coinbaseAddress *account.Address) *RootBlock
- func (b *RootBlock) GetSize() common.StorageSize
- func (b *RootBlock) GetTrackingData() []byte
- func (b *RootBlock) Hash() common.Hash
- func (b *RootBlock) Header() *RootBlockHeader
- func (b *RootBlock) IHeader() IHeader
- func (b *RootBlock) MinorBlockHeader(hash common.Hash) *MinorBlockHeader
- func (b *RootBlock) MinorBlockHeaders() MinorBlockHeaders
- func (b *RootBlock) MinorHeaderHash() common.Hash
- func (b *RootBlock) MixDigest() common.Hash
- func (b *RootBlock) Nonce() uint64
- func (b *RootBlock) Number() uint32
- func (b *RootBlock) NumberU64() uint64
- func (b *RootBlock) ParentHash() common.Hash
- func (b *RootBlock) Serialize(w *[]byte) error
- func (b *RootBlock) Signature() [65]byte
- func (b *RootBlock) Size() common.StorageSize
- func (b *RootBlock) Time() uint64
- func (b *RootBlock) TotalDifficulty() *big.Int
- func (b *RootBlock) TrackingData() []byte
- func (b *RootBlock) Version() uint32
- func (b *RootBlock) WithBody(minorBlockHeaders MinorBlockHeaders, trackingdata []byte) *RootBlock
- func (b *RootBlock) WithMingResult(nonce uint64, mixDigest common.Hash) IBlock
- func (b *RootBlock) WithSeal(header *RootBlockHeader) *RootBlock
- type RootBlockHeader
- func (h *RootBlockHeader) CreateBlockToAppend(createTime *uint64, difficulty *big.Int, address *account.Address, ...) *RootBlock
- func (h *RootBlockHeader) GetCoinbase() account.Address
- func (h *RootBlockHeader) GetCoinbaseAmount() *big.Int
- func (h *RootBlockHeader) GetDifficulty() *big.Int
- func (h *RootBlockHeader) GetExtra() []byte
- func (h *RootBlockHeader) GetMixDigest() common.Hash
- func (h *RootBlockHeader) GetNonce() uint64
- func (h *RootBlockHeader) GetParentHash() common.Hash
- func (h *RootBlockHeader) GetTime() uint64
- func (h *RootBlockHeader) GetTotalDifficulty() *big.Int
- func (h *RootBlockHeader) Hash() common.Hash
- func (h *RootBlockHeader) NumberU64() uint64
- func (h *RootBlockHeader) SealHash() common.Hash
- func (h *RootBlockHeader) SetCoinbase(addr account.Address)
- func (h *RootBlockHeader) SetDifficulty(difficulty *big.Int)
- func (h *RootBlockHeader) SetExtra(data []byte)
- func (h *RootBlockHeader) SetNonce(nonce uint64)
- func (h *RootBlockHeader) SignWithPrivateKey(prv *ecdsa.PrivateKey) error
- func (h *RootBlockHeader) Size() common.StorageSize
- type Signer
- type Transaction
- type Transactions
- type TransactionsByPriceAndNonce
- type TxByNonce
- type TxByPrice
Constants ¶
const ( // BloomByteLength represents the number of bytes used in a header log bloom. BloomByteLength = 256 // BloomBitLength represents the number of bits used in a header log bloom. BloomBitLength = 8 * BloomByteLength )
const ( // ReceiptStatusFailed is the status code of a transaction if execution failed. ReceiptStatusFailed = uint64(0) // ReceiptStatusSuccessful is the status code of a transaction if execution succeeded. ReceiptStatusSuccessful = uint64(1) )
const ( InvalidTxType = iota EvmTx )
Variables ¶
var Bloom9 = bloom9
var EmptyHash = common.Hash{}
var EmptyTrieHash = new(trie.Trie).Hash()
var (
ErrInvalidNetworkId = errors.New("invalid network id for signer")
)
var (
ErrInvalidSig = errors.New("invalid transaction v, r, s values")
)
Functions ¶
func BloomLookup ¶
func CalculateMerkleRoot ¶
func DeriveSha ¶
func DeriveSha(list DerivableList) common.Hash
func Sender ¶
func Sender(signer Signer, tx *EvmTransaction) (account.Recipient, error)
Sender returns the address derived from the signature (V, R, S) using secp256k1 elliptic curve and an error if it failed deriving or upon an incorrect signature.
Sender may cache the address, allowing it to be used regardless of signing method. The cache is invalidated if the cached signer does not match the signer used in the current call.
Types ¶
type Bloom ¶
type Bloom [BloomByteLength]byte
Bloom represents a 2048 bit bloom filter.
func BytesToBloom ¶
BytesToBloom converts a byte slice to a bloom filter. It panics if b is not of suitable size.
func CreateBloom ¶
func (Bloom) MarshalText ¶
MarshalText encodes b as a hex string with 0x prefix.
func (*Bloom) SetBytes ¶
SetBytes sets the content of b to the given bytes. It panics if d is not of suitable size.
func (*Bloom) UnmarshalText ¶
UnmarshalText b as a hex string with 0x prefix.
type ChainMask ¶
type ChainMask struct {
Value uint32
}
func NewChainMask ¶
Represent a mask of chains, basically matches all the bits from the right until the leftmost bit is hit. E.g., mask = 1, matches * mask = 0b10, matches *0 mask = 0b101, matches *01
func (*ChainMask) ContainFullShardId ¶
func (*ChainMask) HasOverlap ¶
type CrossShardTransactionDepositList ¶
type CrossShardTransactionDepositList struct {
TXList []*CrossShardTransactionDeposit `bytesizeofslicelen:"4"`
}
type DerivableList ¶
type EIP155Signer ¶
type EIP155Signer struct {
// contains filtered or unexported fields
}
EIP155Transaction implements Signer using the EIP155 rules.
func NewEIP155Signer ¶
func NewEIP155Signer(networkId uint32) EIP155Signer
func (EIP155Signer) Equal ¶
func (s EIP155Signer) Equal(s2 Signer) bool
func (EIP155Signer) Hash ¶
func (s EIP155Signer) Hash(tx *EvmTransaction) common.Hash
Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.
func (EIP155Signer) Sender ¶
func (s EIP155Signer) Sender(tx *EvmTransaction) (account.Recipient, error)
func (EIP155Signer) SignatureValues ¶
func (s EIP155Signer) SignatureValues(tx *EvmTransaction, sig []byte) (R, S, V *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type EvmTransaction ¶
type EvmTransaction struct { FromShardsize uint32 ToShardsize uint32 // contains filtered or unexported fields }
func NewEvmContractCreation ¶
func NewEvmTransaction ¶
func SignTx ¶
func SignTx(tx *EvmTransaction, s Signer, prv *ecdsa.PrivateKey) (*EvmTransaction, error)
SignTx signs the transaction using the given signer and private key
func (*EvmTransaction) AsMessage ¶
func (tx *EvmTransaction) AsMessage(s Signer) (Message, error)
AsMessage returns the transaction as a core.Message. AsMessage requires a signer to derive the sender. XXX Rename message to something less arbitrary?
func (*EvmTransaction) CheckNonce ¶
func (tx *EvmTransaction) CheckNonce() bool
func (*EvmTransaction) Cost ¶
func (tx *EvmTransaction) Cost() *big.Int
Cost returns amount + gasprice * gaslimit.
func (*EvmTransaction) Data ¶
func (tx *EvmTransaction) Data() []byte
func (*EvmTransaction) DecodeRLP ¶
func (tx *EvmTransaction) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder
func (*EvmTransaction) EncodeRLP ¶
func (tx *EvmTransaction) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder
func (*EvmTransaction) FromChainID ¶
func (tx *EvmTransaction) FromChainID() uint32
func (*EvmTransaction) FromFullShardId ¶
func (tx *EvmTransaction) FromFullShardId() uint32
func (*EvmTransaction) FromFullShardKey ¶
func (tx *EvmTransaction) FromFullShardKey() uint32
func (*EvmTransaction) FromShardID ¶
func (tx *EvmTransaction) FromShardID() uint32
func (*EvmTransaction) FromShardSize ¶
func (tx *EvmTransaction) FromShardSize() uint32
func (*EvmTransaction) Gas ¶
func (tx *EvmTransaction) Gas() uint64
func (*EvmTransaction) GasPrice ¶
func (tx *EvmTransaction) GasPrice() *big.Int
func (*EvmTransaction) Hash ¶
func (tx *EvmTransaction) Hash() common.Hash
Hash hashes the RLP encoding of tx. It uniquely identifies the transaction.
func (*EvmTransaction) IsCrossShard ¶
func (tx *EvmTransaction) IsCrossShard() bool
func (*EvmTransaction) NetworkId ¶
func (tx *EvmTransaction) NetworkId() uint32
func (*EvmTransaction) Nonce ¶
func (tx *EvmTransaction) Nonce() uint64
func (*EvmTransaction) RawSignatureValues ¶
func (*EvmTransaction) SetFromShardSize ¶
func (tx *EvmTransaction) SetFromShardSize(shardSize uint32) error
func (*EvmTransaction) SetGas ¶
func (e *EvmTransaction) SetGas(data uint64)
func (*EvmTransaction) SetNonce ¶
func (e *EvmTransaction) SetNonce(data uint64)
func (*EvmTransaction) SetToShardSize ¶
func (tx *EvmTransaction) SetToShardSize(shardSize uint32) error
func (*EvmTransaction) SetVRS ¶
func (e *EvmTransaction) SetVRS(v, r, s *big.Int)
func (*EvmTransaction) Size ¶
func (tx *EvmTransaction) Size() common.StorageSize
Size returns the true RLP encoded storage size of the transaction, either by encoding and returning it, or returning a previsouly cached value.
func (*EvmTransaction) To ¶
func (tx *EvmTransaction) To() *account.Recipient
To returns the recipient address of the transaction. It returns nil if the transaction is a contract creation.
func (*EvmTransaction) ToChainID ¶
func (tx *EvmTransaction) ToChainID() uint32
func (*EvmTransaction) ToFullShardId ¶
func (tx *EvmTransaction) ToFullShardId() uint32
func (*EvmTransaction) ToFullShardKey ¶
func (tx *EvmTransaction) ToFullShardKey() uint32
func (*EvmTransaction) ToShardID ¶
func (tx *EvmTransaction) ToShardID() uint32
func (*EvmTransaction) ToShardSize ¶
func (tx *EvmTransaction) ToShardSize() uint32
func (*EvmTransaction) Value ¶
func (tx *EvmTransaction) Value() *big.Int
func (*EvmTransaction) Version ¶
func (tx *EvmTransaction) Version() uint32
func (*EvmTransaction) WithSignature ¶
func (tx *EvmTransaction) WithSignature(signer Signer, sig []byte) (*EvmTransaction, error)
WithSignature returns a new transaction with the given signature. This signature needs to be formatted as described in the yellow paper (v+27).
type IHeader ¶
type IHeader interface { Hash() common.Hash SealHash() common.Hash NumberU64() uint64 GetParentHash() common.Hash GetCoinbase() account.Address GetTime() uint64 GetCoinbaseAmount() *big.Int GetDifficulty() *big.Int GetTotalDifficulty() *big.Int GetNonce() uint64 GetExtra() []byte SetCoinbase(account.Address) SetExtra([]byte) SetDifficulty(*big.Int) SetNonce(uint64) GetMixDigest() common.Hash }
type Log ¶
type Log struct { // Consensus fields: // address of the contract that generated the event Recipient account.Recipient `json:"address" gencodec:"required"` // list of topics provided by the contract. Topics []common.Hash `json:"topics" gencodec:"required"` // supplied by the contract, usually ABI-encoded Data []byte `json:"data" gencodec:"required" bytesizeofslicelen:"4"` // Derived fields. These fields are filled in by the node // but not secured by consensus. // block in which the transaction was included BlockNumber uint64 `json:"blockNumber"` // hash of the transaction TxHash common.Hash `json:"transactionHash" gencodec:"required"` // index of the transaction in the block TxIndex uint32 `json:"transactionIndex" gencodec:"required"` // hash of the block in which the transaction was included BlockHash common.Hash `json:"blockHash"` // index of the log in the block Index uint32 `json:"logIndex" gencodec:"required"` // The Removed field is true if this log was reverted due to a chain reorganisation. // You must pay attention to this field if you receive logs through a filter query. Removed bool `json:"removed" ser:"-"` }
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 Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is a fully derived transaction and implements core.Message
NOTE: In a future PR this will be removed.
func NewMessage ¶
func (Message) CheckNonce ¶
func (Message) FromFullShardKey ¶
func (Message) IsCrossShard ¶
func (Message) ToFullShardKey ¶
type MinorBlock ¶
type MinorBlock struct { // These fields are used by package eth to track // inter-peer block relay. ReceivedAt time.Time ReceivedFrom interface{} // contains filtered or unexported fields }
MinorBlock represents an entire block in the Ethereum blockchain.
func NewMinorBlock ¶
func NewMinorBlock(header *MinorBlockHeader, meta *MinorBlockMeta, txs []*Transaction, receipts []*Receipt, trackingdata []byte) *MinorBlock
NewBlock creates a new block. The input data is copied, changes to header and to the field values will not affect the block.
The values of Root, ReceiptHash and Bloom in header are ignored and set to values derived from the given txs and receipts.
func NewMinorBlockWithHeader ¶
func NewMinorBlockWithHeader(header *MinorBlockHeader, meta *MinorBlockMeta) *MinorBlock
NewBlockWithHeader creates a block with the given header data. The header data is copied, changes to header and to the field values will not affect the block.
func (*MinorBlock) AddTx ¶
func (h *MinorBlock) AddTx(tx *Transaction)
func (*MinorBlock) Bloom ¶
func (b *MinorBlock) Bloom() Bloom
func (*MinorBlock) Branch ¶
func (b *MinorBlock) Branch() account.Branch
func (*MinorBlock) Coinbase ¶
func (b *MinorBlock) Coinbase() account.Address
func (*MinorBlock) CoinbaseAmount ¶
func (b *MinorBlock) CoinbaseAmount() *big.Int
func (*MinorBlock) Content ¶
func (b *MinorBlock) Content() []IHashable
func (*MinorBlock) CreateBlockToAppend ¶
func (*MinorBlock) CrossShardGasUsed ¶
func (b *MinorBlock) CrossShardGasUsed() *big.Int
func (*MinorBlock) Deserialize ¶
func (b *MinorBlock) Deserialize(bb *serialize.ByteBuffer) error
Deserialize deserialize the QKC minor block
func (*MinorBlock) Difficulty ¶
func (b *MinorBlock) Difficulty() *big.Int
func (*MinorBlock) Extra ¶
func (b *MinorBlock) Extra() []byte
func (*MinorBlock) GasLimit ¶
func (b *MinorBlock) GasLimit() *big.Int
func (*MinorBlock) GasUsed ¶
func (b *MinorBlock) GasUsed() *big.Int
func (*MinorBlock) GetMetaData ¶
func (b *MinorBlock) GetMetaData() *MinorBlockMeta
func (*MinorBlock) GetSize ¶
func (b *MinorBlock) GetSize() common.StorageSize
func (*MinorBlock) GetTrackingData ¶
func (b *MinorBlock) GetTrackingData() []byte
func (*MinorBlock) GetTransactions ¶
func (b *MinorBlock) GetTransactions() Transactions
func (*MinorBlock) Hash ¶
func (b *MinorBlock) Hash() common.Hash
Hash returns the keccak256 hash of b's header. The hash is computed on the first call and cached thereafter.
func (*MinorBlock) Header ¶
func (b *MinorBlock) Header() *MinorBlockHeader
func (*MinorBlock) IHeader ¶
func (b *MinorBlock) IHeader() IHeader
func (*MinorBlock) Meta ¶
func (b *MinorBlock) Meta() *MinorBlockMeta
func (*MinorBlock) MetaHash ¶
func (b *MinorBlock) MetaHash() common.Hash
func (*MinorBlock) MixDigest ¶
func (b *MinorBlock) MixDigest() common.Hash
func (*MinorBlock) Nonce ¶
func (b *MinorBlock) Nonce() uint64
func (*MinorBlock) Number ¶
func (b *MinorBlock) Number() uint64
func (*MinorBlock) NumberU64 ¶
func (b *MinorBlock) NumberU64() uint64
func (*MinorBlock) ParentHash ¶
func (b *MinorBlock) ParentHash() common.Hash
func (*MinorBlock) PrevRootBlockHash ¶
func (b *MinorBlock) PrevRootBlockHash() common.Hash
func (*MinorBlock) ReceiptHash ¶
func (b *MinorBlock) ReceiptHash() common.Hash
func (*MinorBlock) Serialize ¶
func (b *MinorBlock) Serialize(w *[]byte) error
Serialize serialize the QKC minor block.
func (*MinorBlock) Size ¶
func (b *MinorBlock) Size() common.StorageSize
Size returns the true RLP encoded storage size of the block, either by encoding and returning it, or returning a previsouly cached value.
func (*MinorBlock) Time ¶
func (b *MinorBlock) Time() uint64
func (*MinorBlock) TrackingData ¶
func (b *MinorBlock) TrackingData() []byte
func (*MinorBlock) Transaction ¶
func (b *MinorBlock) Transaction(hash common.Hash) *Transaction
func (*MinorBlock) Transactions ¶
func (b *MinorBlock) Transactions() Transactions
func (*MinorBlock) TxHash ¶
func (b *MinorBlock) TxHash() common.Hash
func (*MinorBlock) WithBody ¶
func (b *MinorBlock) WithBody(transactions []*Transaction, trackingData []byte) *MinorBlock
WithBody returns a new block with the given transaction and uncle contents.
func (*MinorBlock) WithMingResult ¶
func (b *MinorBlock) WithMingResult(nonce uint64, mixDigest common.Hash) IBlock
WithMingResult returns a new block with the data from b and update nonce and mixDigest
func (*MinorBlock) WithSeal ¶
func (b *MinorBlock) WithSeal(header *MinorBlockHeader) *MinorBlock
WithSeal returns a new block with the data from b but the header replaced with the sealed one.
type MinorBlockHeader ¶
type MinorBlockHeader struct { Version uint32 `json:"version" gencodec:"required"` Branch account.Branch `json:"branch" gencodec:"required"` Number uint64 `json:"number" gencodec:"required"` Coinbase account.Address `json:"miner" gencodec:"required"` CoinbaseAmount *serialize.Uint256 `json:"coinbaseAmount" gencodec:"required"` ParentHash common.Hash `json:"parentHash" gencodec:"required"` PrevRootBlockHash common.Hash `json:"prevRootBlockHash" gencodec:"required"` GasLimit *serialize.Uint256 `json:"gasLimit" gencodec:"required"` MetaHash common.Hash `json:"metaHash" gencodec:"required"` Time uint64 `json:"timestamp" gencodec:"required"` Difficulty *big.Int `json:"difficulty" gencodec:"required"` Nonce uint64 `json:"nonce"` Bloom Bloom `json:"logsBloom" gencodec:"required"` Extra []byte `json:"extraData" gencodec:"required" bytesizeofslicelen:"2"` MixDigest common.Hash `json:"mixHash"` }
MinorBlockHeaderList represents a minor block header in the QuarkChain.
func CopyMinorBlockHeader ¶
func CopyMinorBlockHeader(h *MinorBlockHeader) *MinorBlockHeader
CopyHeader creates a deep copy of a block header to prevent side effects from modifying a header variable.
func (*MinorBlockHeader) GetBloom ¶
func (h *MinorBlockHeader) GetBloom() Bloom
func (*MinorBlockHeader) GetBranch ¶
func (h *MinorBlockHeader) GetBranch() account.Branch
func (*MinorBlockHeader) GetCoinbase ¶
func (h *MinorBlockHeader) GetCoinbase() account.Address
func (*MinorBlockHeader) GetCoinbaseAmount ¶
func (h *MinorBlockHeader) GetCoinbaseAmount() *big.Int
func (*MinorBlockHeader) GetDifficulty ¶
func (h *MinorBlockHeader) GetDifficulty() *big.Int
func (*MinorBlockHeader) GetExtra ¶
func (h *MinorBlockHeader) GetExtra() []byte
func (*MinorBlockHeader) GetGasLimit ¶
func (h *MinorBlockHeader) GetGasLimit() *big.Int
func (*MinorBlockHeader) GetMetaHash ¶
func (h *MinorBlockHeader) GetMetaHash() common.Hash
func (*MinorBlockHeader) GetMixDigest ¶
func (h *MinorBlockHeader) GetMixDigest() common.Hash
func (*MinorBlockHeader) GetNonce ¶
func (h *MinorBlockHeader) GetNonce() uint64
func (*MinorBlockHeader) GetParentHash ¶
func (h *MinorBlockHeader) GetParentHash() common.Hash
func (*MinorBlockHeader) GetPrevRootBlockHash ¶
func (h *MinorBlockHeader) GetPrevRootBlockHash() common.Hash
func (*MinorBlockHeader) GetTime ¶
func (h *MinorBlockHeader) GetTime() uint64
func (*MinorBlockHeader) GetTotalDifficulty ¶
func (h *MinorBlockHeader) GetTotalDifficulty() *big.Int
func (*MinorBlockHeader) Hash ¶
func (h *MinorBlockHeader) Hash() common.Hash
Hash returns the block hash of the header, which is simply the keccak256 hash of its Serialize encoding.
func (*MinorBlockHeader) NumberU64 ¶
func (h *MinorBlockHeader) NumberU64() uint64
func (*MinorBlockHeader) SealHash ¶
func (h *MinorBlockHeader) SealHash() common.Hash
SealHash returns the block hash of the header, which is keccak256 hash of its Serialize encoding for Seal.
func (*MinorBlockHeader) SetCoinbase ¶
func (h *MinorBlockHeader) SetCoinbase(addr account.Address)
func (*MinorBlockHeader) SetDifficulty ¶
func (h *MinorBlockHeader) SetDifficulty(difficulty *big.Int)
func (*MinorBlockHeader) SetExtra ¶
func (h *MinorBlockHeader) SetExtra(data []byte)
func (*MinorBlockHeader) SetNonce ¶
func (h *MinorBlockHeader) SetNonce(nonce uint64)
func (*MinorBlockHeader) Size ¶
func (h *MinorBlockHeader) Size() common.StorageSize
Size returns the approximate memory used by all internal contents. It is used to approximate and limit the memory consumption of various caches.
type MinorBlockHeaders ¶
type MinorBlockHeaders []*MinorBlockHeader
MinorBlockHeaders is a MinorBlockHeaderList slice type for basic sorting.
func MinorHeaderDifference ¶
func MinorHeaderDifference(a, b MinorBlockHeaders) MinorBlockHeaders
MinorHeaderDifference returns a new set which is the difference between a and b.
func (MinorBlockHeaders) Bytes ¶
func (s MinorBlockHeaders) Bytes(i int) []byte
Bytes implements DerivableList and returns the i'th element of s in serialize.
func (MinorBlockHeaders) Swap ¶
func (s MinorBlockHeaders) Swap(i, j int)
Swap swaps the i'th and the j'th element in s.
type MinorBlockMeta ¶
type MinorBlockMeta struct { TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` Root common.Hash `json:"stateRoot" gencodec:"required"` ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` GasUsed *serialize.Uint256 `json:"gasUsed" gencodec:"required"` CrossShardGasUsed *serialize.Uint256 `json:"crossShardGasUsed" gencodec:"required"` }
func CopyMinorBlockMeta ¶
func CopyMinorBlockMeta(m *MinorBlockMeta) *MinorBlockMeta
func (*MinorBlockMeta) Hash ¶
func (m *MinorBlockMeta) Hash() common.Hash
type Receipt ¶
type Receipt struct { // Consensus fields PostState []byte `json:"root"` Status uint64 `json:"status"` CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"` Bloom Bloom `json:"logsBloom" gencodec:"required"` Logs []*Log `json:"logs" gencodec:"required"` // Implementation fields (don't reorder!) TxHash common.Hash `json:"transactionHash" gencodec:"required"` ContractAddress account.Recipient `json:"contractAddress"` ContractFullShardId uint32 `json:"contractFullShardId"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` }
Receipt represents the results of a transaction.
func NewReceipt ¶
NewReceipt creates a barebone transaction receipt, copying the init fields.
func (*Receipt) DecodeRLP ¶
DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt from an RLP stream.
func (*Receipt) Deserialize ¶
func (r *Receipt) Deserialize(bb *serialize.ByteBuffer) error
Deserialize deserialize the QKC minor block
func (*Receipt) EncodeRLP ¶
EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt into an RLP stream. If no post state is present, byzantium fork is assumed.
func (*Receipt) GetPrevGasUsed ¶
func (*Receipt) Size ¶
func (r *Receipt) Size() common.StorageSize
Size returns the approximate memory used by all internal contents. It is used to approximate and limit the memory consumption of various caches.
type ReceiptForStorage ¶
type ReceiptForStorage Receipt
ReceiptForStorage is a wrapper around a Receipt that flattens and parses the entire content of a receipt, as opposed to only the consensus fields originally.
type Receipts ¶
type Receipts []*Receipt
Receipts is a wrapper around a Receipt array to implement DerivableList.
type RootBlock ¶
type RootBlock struct { // These fields are used by package eth to track // inter-peer block relay. ReceivedAt time.Time ReceivedFrom interface{} // contains filtered or unexported fields }
Block represents an entire block in the QuarkChain.
func NewRootBlock ¶
func NewRootBlock(header *RootBlockHeader, mbHeaders MinorBlockHeaders, trackingdata []byte) *RootBlock
NewBlock creates a new block. The input data is copied, changes to header and to the field values will not affect the block.
The values of MinorHeaderHash, ReceiptHash and Bloom in header are ignored and set to values derived from the given txs, uncles and receipts.
func NewRootBlockWithHeader ¶
func NewRootBlockWithHeader(header *RootBlockHeader) *RootBlock
NewBlockWithHeader creates a block with the given header data. The header data is copied, changes to header and to the field values will not affect the block.
func (*RootBlock) AddMinorBlockHeader ¶
func (b *RootBlock) AddMinorBlockHeader(header *MinorBlockHeader)
func (*RootBlock) CoinbaseAmount ¶
func (*RootBlock) Deserialize ¶
func (b *RootBlock) Deserialize(bb *serialize.ByteBuffer) error
Deserialize deserialize the QKC root block
func (*RootBlock) Difficulty ¶
func (*RootBlock) ExtendMinorBlockHeaderList ¶
func (b *RootBlock) ExtendMinorBlockHeaderList(headers []*MinorBlockHeader)
func (*RootBlock) GetSize ¶
func (b *RootBlock) GetSize() common.StorageSize
func (*RootBlock) GetTrackingData ¶
func (*RootBlock) Hash ¶
Hash returns the keccak256 hash of b's header. The hash is computed on the first call and cached thereafter.
func (*RootBlock) Header ¶
func (b *RootBlock) Header() *RootBlockHeader
func (*RootBlock) MinorBlockHeader ¶
func (b *RootBlock) MinorBlockHeader(hash common.Hash) *MinorBlockHeader
func (*RootBlock) MinorBlockHeaders ¶
func (b *RootBlock) MinorBlockHeaders() MinorBlockHeaders
func (*RootBlock) MinorHeaderHash ¶
func (*RootBlock) ParentHash ¶
func (*RootBlock) Size ¶
func (b *RootBlock) Size() common.StorageSize
func (*RootBlock) TotalDifficulty ¶
func (*RootBlock) TrackingData ¶
func (*RootBlock) WithBody ¶
func (b *RootBlock) WithBody(minorBlockHeaders MinorBlockHeaders, trackingdata []byte) *RootBlock
WithBody returns a new block with the given minorBlockHeaders contents.
func (*RootBlock) WithMingResult ¶
WithMingResult returns a new block with the data from b and update nonce and mixDigest
func (*RootBlock) WithSeal ¶
func (b *RootBlock) WithSeal(header *RootBlockHeader) *RootBlock
WithSeal returns a new block with the data from b but the header replaced with the sealed one.
type RootBlockHeader ¶
type RootBlockHeader struct { Version uint32 `json:"version" gencodec:"required"` Number uint32 `json:"number" gencodec:"required"` ParentHash common.Hash `json:"parentHash" gencodec:"required"` MinorHeaderHash common.Hash `json:"transactionsRoot" gencodec:"required"` Coinbase account.Address `json:"miner" gencodec:"required"` CoinbaseAmount *serialize.Uint256 `json:"coinbaseAmount" gencodec:"required"` Time uint64 `json:"timestamp" gencodec:"required"` Difficulty *big.Int `json:"difficulty" gencodec:"required"` ToTalDifficulty *big.Int `json:"total_difficulty" gencodec:"required"` Nonce uint64 `json:"nonce"` Extra []byte `json:"extraData" gencodec:"required" bytesizeofslicelen:"2"` MixDigest common.Hash `json:"mixHash"` Signature [65]byte `json:"signature" gencodec:"required"` }
RootBlockHeader represents a root block header in the QuarkChain.
func CopyRootBlockHeader ¶
func CopyRootBlockHeader(h *RootBlockHeader) *RootBlockHeader
CopyRootHeader creates a deep copy of a block header to prevent side effects from modifying a header variable.
func (*RootBlockHeader) CreateBlockToAppend ¶
func (*RootBlockHeader) GetCoinbase ¶
func (h *RootBlockHeader) GetCoinbase() account.Address
func (*RootBlockHeader) GetCoinbaseAmount ¶
func (h *RootBlockHeader) GetCoinbaseAmount() *big.Int
func (*RootBlockHeader) GetDifficulty ¶
func (h *RootBlockHeader) GetDifficulty() *big.Int
func (*RootBlockHeader) GetExtra ¶
func (h *RootBlockHeader) GetExtra() []byte
func (*RootBlockHeader) GetMixDigest ¶
func (h *RootBlockHeader) GetMixDigest() common.Hash
func (*RootBlockHeader) GetNonce ¶
func (h *RootBlockHeader) GetNonce() uint64
func (*RootBlockHeader) GetParentHash ¶
func (h *RootBlockHeader) GetParentHash() common.Hash
func (*RootBlockHeader) GetTime ¶
func (h *RootBlockHeader) GetTime() uint64
func (*RootBlockHeader) GetTotalDifficulty ¶
func (h *RootBlockHeader) GetTotalDifficulty() *big.Int
func (*RootBlockHeader) Hash ¶
func (h *RootBlockHeader) Hash() common.Hash
Hash returns the block hash of the header, which is simply the keccak256 hash of its Serialize encoding.
func (*RootBlockHeader) NumberU64 ¶
func (h *RootBlockHeader) NumberU64() uint64
func (*RootBlockHeader) SealHash ¶
func (h *RootBlockHeader) SealHash() common.Hash
SealHash returns the block hash of the header, which is keccak256 hash of its Serialize encoding for Seal.
func (*RootBlockHeader) SetCoinbase ¶
func (h *RootBlockHeader) SetCoinbase(addr account.Address)
func (*RootBlockHeader) SetDifficulty ¶
func (h *RootBlockHeader) SetDifficulty(difficulty *big.Int)
func (*RootBlockHeader) SetExtra ¶
func (h *RootBlockHeader) SetExtra(data []byte)
func (*RootBlockHeader) SetNonce ¶
func (h *RootBlockHeader) SetNonce(nonce uint64)
func (*RootBlockHeader) SignWithPrivateKey ¶
func (h *RootBlockHeader) SignWithPrivateKey(prv *ecdsa.PrivateKey) error
func (*RootBlockHeader) Size ¶
func (h *RootBlockHeader) Size() common.StorageSize
Size returns the approximate memory used by all internal contents. It is used to approximate and limit the memory consumption of various caches.
type Signer ¶
type Signer interface { // Sender returns the sender address of the transaction. Sender(tx *EvmTransaction) (account.Recipient, error) // SignatureValues returns the raw R, S, V values corresponding to the // given signature. SignatureValues(tx *EvmTransaction, sig []byte) (r, s, v *big.Int, err error) // Hash returns the hash to be signed. Hash(tx *EvmTransaction) common.Hash // Equal returns true if the given signer is the same as the receiver. Equal(Signer) bool }
Signer encapsulates transaction signature handling. Note that this interface is not a stable API and may change at any time to accommodate new protocol rules.
func MakeSigner ¶
MakeSigner returns a Signer based on the given chain config and block number.
type Transaction ¶
type Transaction struct { TxType uint8 EvmTx *EvmTransaction // contains filtered or unexported fields }
func (*Transaction) Deserialize ¶
func (tx *Transaction) Deserialize(bb *serialize.ByteBuffer) error
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() (h common.Hash)
Hash return the hash of the transaction it contained
func (*Transaction) Sender ¶
func (tx *Transaction) Sender(signer Signer) (account.Recipient, error)
func (*Transaction) Serialize ¶
func (tx *Transaction) Serialize(w *[]byte) error
type Transactions ¶
type Transactions []*Transaction
Transactions is a EvmTransaction slice type for basic sorting.
func TxDifference ¶
func TxDifference(a, b Transactions) Transactions
TxDifference returns a new set which is the difference between a and b.
func (Transactions) Bytes ¶
func (s Transactions) Bytes(i int) []byte
func (Transactions) Swap ¶
func (s Transactions) Swap(i, j int)
Swap swaps the i'th and the j'th element in s.
type TransactionsByPriceAndNonce ¶
type TransactionsByPriceAndNonce struct {
// contains filtered or unexported fields
}
TransactionsByPriceAndNonce represents a set of transactions that can return transactions in a profit-maximizing sorted order, while supporting removing entire batches of transactions for non-executable accounts.
func NewTransactionsByPriceAndNonce ¶
func NewTransactionsByPriceAndNonce(signer Signer, txs map[account.Recipient]Transactions) (*TransactionsByPriceAndNonce, error)
NewTransactionsByPriceAndNonce creates a transaction set that can retrieve price sorted transactions in a nonce-honouring way.
Note, the input map is reowned so the caller should not interact any more with if after providing it to the constructor.
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 transaction, *not* replacing it with the next one from the same account. This should be used when a transaction cannot be executed and hence all subsequent ones should be discarded from the same account.
func (*TransactionsByPriceAndNonce) Shift ¶
func (t *TransactionsByPriceAndNonce) Shift() error
Shift replaces the current best head with the next one from the same account.
type TxByNonce ¶
type TxByNonce Transactions
TxByNonce implements the sort interface to allow sorting a list of transactions by their nonces. This is usually only useful for sorting transactions from a single account, otherwise a nonce comparison doesn't make much sense.
type TxByPrice ¶
type TxByPrice Transactions
TxByPrice implements both the sort and the heap interface, making it useful for all at once sorting as well as individually adding and removing elements.