types

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2019 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Modified from go-ethereum under GNU Lesser General Public License

Index

Constants

View Source
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
)
View Source
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)
)
View Source
const (
	InvalidTxType = iota
	EvmTx
)

Variables

View Source
var Bloom9 = bloom9
View Source
var EmptyHash = common.Hash{}
View Source
var EmptyTrieHash = new(trie.Trie).Hash()
View Source
var (
	ErrInvalidNetworkId = errors.New("invalid network id for signer")
)
View Source
var (
	ErrInvalidSig = errors.New("invalid transaction v, r, s values")
)

Functions

func BloomLookup

func BloomLookup(bin Bloom, topic bytesBacked) bool

func CalculateMerkleRoot

func CalculateMerkleRoot(list interface{}) (h common.Hash)

func DeriveSha

func DeriveSha(list DerivableList) common.Hash

func LogsBloom

func LogsBloom(logs []*Log) *big.Int

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

func BytesToBloom(b []byte) Bloom

BytesToBloom converts a byte slice to a bloom filter. It panics if b is not of suitable size.

func CreateBloom

func CreateBloom(receipts Receipts) Bloom

func (*Bloom) Add

func (b *Bloom) Add(d *big.Int)

Add adds d to the filter. Future calls of Test(d) will return true.

func (Bloom) Big

func (b Bloom) Big() *big.Int

Big converts b to a big integer.

func (Bloom) Bytes

func (b Bloom) Bytes() []byte

func (Bloom) MarshalText

func (b Bloom) MarshalText() ([]byte, error)

MarshalText encodes b as a hex string with 0x prefix.

func (*Bloom) SetBytes

func (b *Bloom) SetBytes(d []byte)

SetBytes sets the content of b to the given bytes. It panics if d is not of suitable size.

func (Bloom) Test

func (b Bloom) Test(test *big.Int) bool

func (Bloom) TestBytes

func (b Bloom) TestBytes(test []byte) bool

func (*Bloom) UnmarshalText

func (b *Bloom) UnmarshalText(input []byte) error

UnmarshalText b as a hex string with 0x prefix.

type ChainMask

type ChainMask struct {
	Value uint32
}

func NewChainMask

func NewChainMask(value uint32) *ChainMask

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) ContainBranch

func (c *ChainMask) ContainBranch(branch account.Branch) bool

func (*ChainMask) ContainFullShardId

func (c *ChainMask) ContainFullShardId(fullShardId uint32) bool

func (*ChainMask) GetMask

func (c *ChainMask) GetMask() uint32

func (*ChainMask) HasOverlap

func (c *ChainMask) HasOverlap(value uint32) bool

type CrossShardTransactionDeposit

type CrossShardTransactionDeposit struct {
	TxHash   common.Hash
	From     account.Address
	To       account.Address
	Value    *serialize.Uint256
	GasPrice *serialize.Uint256
}

type CrossShardTransactionDepositList

type CrossShardTransactionDepositList struct {
	TXList []*CrossShardTransactionDeposit `bytesizeofslicelen:"4"`
}

type DerivableList

type DerivableList interface {
	Len() int
	Bytes(i int) []byte
}

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 (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 NewEvmContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, fromFullShardKey uint32, toFullShardKey uint32, networkId uint32, version uint32, data []byte) *EvmTransaction

func NewEvmTransaction

func NewEvmTransaction(nonce uint64, to account.Recipient, amount *big.Int, gasLimit uint64, gasPrice *big.Int, fromFullShardKey uint32, toFullShardKey uint32, networkId uint32, version uint32, data []byte) *EvmTransaction

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 (tx *EvmTransaction) RawSignatureValues() (*big.Int, *big.Int, *big.Int)

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 IBlock

type IBlock interface {
	Hash() common.Hash
	NumberU64() uint64
	IHeader() IHeader
	WithMingResult(nonce uint64, mixDigest common.Hash) IBlock
	Content() []IHashable
	GetTrackingData() []byte
	GetSize() common.StorageSize
	CoinbaseAmount() *big.Int
}

type IHashable

type IHashable interface {
	Hash() common.Hash
}

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.

func (*Log) DecodeRLP

func (l *Log) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder.

func (*Log) EncodeRLP

func (l *Log) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder.

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.

func (*LogForStorage) DecodeRLP

func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder.

func (*LogForStorage) EncodeRLP

func (l *LogForStorage) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder.

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 NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool, fromShardId, toShardId uint32) Message

func (Message) CheckNonce

func (m Message) CheckNonce() bool

func (Message) Data

func (m Message) Data() []byte

func (Message) From

func (m Message) From() common.Address

func (Message) FromFullShardKey

func (m Message) FromFullShardKey() uint32

func (Message) Gas

func (m Message) Gas() uint64

func (Message) GasPrice

func (m Message) GasPrice() *big.Int

func (Message) IsCrossShard

func (m Message) IsCrossShard() bool

func (Message) Nonce

func (m Message) Nonce() uint64

func (Message) To

func (m Message) To() *common.Address

func (Message) ToFullShardKey

func (m Message) ToFullShardKey() uint32

func (Message) TxHash

func (m Message) TxHash() common.Hash

func (Message) Value

func (m Message) Value() *big.Int

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 (h *MinorBlock) CreateBlockToAppend(createTime *uint64, difficulty *big.Int, address *account.Address, nonce *uint64, gasLimit *big.Int, extraData []byte, coinbaseAmount *big.Int) *MinorBlock

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) Finalize

func (m *MinorBlock) Finalize(receipts Receipts, rootHash common.Hash, gasUsed *big.Int, xShardReceiveGasUsed *big.Int, coinbaseAmount *big.Int)

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) Root

func (b *MinorBlock) Root() common.Hash

meta properties

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) Version

func (b *MinorBlock) Version() uint32

header properties

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

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) Len

func (s MinorBlockHeaders) Len() int

Len returns the length of s.

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

func NewReceipt(root []byte, failed bool, cumulativeGasUsed uint64) *Receipt

NewReceipt creates a barebone transaction receipt, copying the init fields.

func (*Receipt) DecodeRLP

func (r *Receipt) DecodeRLP(s *rlp.Stream) error

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

func (r *Receipt) EncodeRLP(w io.Writer) error

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 (r *Receipt) GetPrevGasUsed() uint64

func (*Receipt) Serialize

func (r *Receipt) Serialize(w *[]byte) error

Serialize serialize the QKC minor block.

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.

func (*ReceiptForStorage) DecodeRLP

func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and loads both consensus and implementation fields of a receipt from an RLP stream.

func (*ReceiptForStorage) EncodeRLP

func (r *ReceiptForStorage) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, and flattens all content fields of a receipt into an RLP stream.

type Receipts

type Receipts []*Receipt

Receipts is a wrapper around a Receipt array to implement DerivableList.

func (Receipts) Bytes

func (r Receipts) Bytes(i int) []byte

GetRlp returns the RLP encoding of one receipt from the list.

func (Receipts) Len

func (r Receipts) Len() int

Len returns the number of receipts in this list.

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) Coinbase

func (b *RootBlock) Coinbase() account.Address

func (*RootBlock) CoinbaseAmount

func (b *RootBlock) CoinbaseAmount() *big.Int

func (*RootBlock) Content

func (b *RootBlock) Content() []IHashable

func (*RootBlock) Deserialize

func (b *RootBlock) Deserialize(bb *serialize.ByteBuffer) error

Deserialize deserialize the QKC root block

func (*RootBlock) Difficulty

func (b *RootBlock) Difficulty() *big.Int

func (*RootBlock) ExtendMinorBlockHeaderList

func (b *RootBlock) ExtendMinorBlockHeaderList(headers []*MinorBlockHeader)

func (*RootBlock) Extra

func (b *RootBlock) Extra() []byte

func (*RootBlock) Finalize

func (b *RootBlock) Finalize(coinbaseAmount *big.Int, coinbaseAddress *account.Address) *RootBlock

func (*RootBlock) GetSize

func (b *RootBlock) GetSize() common.StorageSize

func (*RootBlock) GetTrackingData

func (b *RootBlock) GetTrackingData() []byte

func (*RootBlock) Hash

func (b *RootBlock) Hash() common.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) IHeader

func (b *RootBlock) IHeader() IHeader

func (*RootBlock) MinorBlockHeader

func (b *RootBlock) MinorBlockHeader(hash common.Hash) *MinorBlockHeader

func (*RootBlock) MinorBlockHeaders

func (b *RootBlock) MinorBlockHeaders() MinorBlockHeaders

func (*RootBlock) MinorHeaderHash

func (b *RootBlock) MinorHeaderHash() common.Hash

func (*RootBlock) MixDigest

func (b *RootBlock) MixDigest() common.Hash

func (*RootBlock) Nonce

func (b *RootBlock) Nonce() uint64

func (*RootBlock) Number

func (b *RootBlock) Number() uint32

func (*RootBlock) NumberU64

func (b *RootBlock) NumberU64() uint64

func (*RootBlock) ParentHash

func (b *RootBlock) ParentHash() common.Hash

func (*RootBlock) Serialize

func (b *RootBlock) Serialize(w *[]byte) error

Serialize serialize the QKC root block.

func (*RootBlock) Signature

func (b *RootBlock) Signature() [65]byte

func (*RootBlock) Size

func (b *RootBlock) Size() common.StorageSize

func (*RootBlock) Time

func (b *RootBlock) Time() uint64

func (*RootBlock) TotalDifficulty

func (b *RootBlock) TotalDifficulty() *big.Int

func (*RootBlock) TrackingData

func (b *RootBlock) TrackingData() []byte

func (*RootBlock) Version

func (b *RootBlock) Version() uint32

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

func (b *RootBlock) WithMingResult(nonce uint64, mixDigest common.Hash) IBlock

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 (h *RootBlockHeader) CreateBlockToAppend(createTime *uint64, difficulty *big.Int, address *account.Address, nonce *uint64, extraData []byte) *RootBlock

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

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

func MakeSigner(networkId uint32) Signer

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) Len

func (s Transactions) Len() int

Len returns the length of s.

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

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

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.

func (TxByNonce) Len

func (s TxByNonce) Len() int

func (TxByNonce) Less

func (s TxByNonce) Less(i, j int) bool

func (TxByNonce) Swap

func (s TxByNonce) Swap(i, j int)

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.

func (TxByPrice) Len

func (s TxByPrice) Len() int

func (TxByPrice) Less

func (s TxByPrice) Less(i, j int) bool

func (*TxByPrice) Pop

func (s *TxByPrice) Pop() interface{}

func (*TxByPrice) Push

func (s *TxByPrice) Push(x interface{})

func (TxByPrice) Swap

func (s TxByPrice) Swap(i, j int)

Jump to

Keyboard shortcuts

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