Documentation ¶
Overview ¶
Package types contains data types related to Shx consensus.
Index ¶
- Constants
- Variables
- func ASynrecoverPlain(tx *Transaction, sighash common.Hash, R, S, Vb *big.Int) (common.Address, error)
- func BloomLookup(bin Bloom, topic bytesBacked) bool
- func DeriveSha(list DerivableList) common.Hash
- func DeriveShaWithTree(list DerivableList) common.Hash
- func LogsBloom(logs []*Log) *big.Int
- func Number(b1, b2 *Block) bool
- type Block
- func (b *Block) Body() *Body
- func (b *Block) Coinbase() common.Address
- func (b *Block) DecodeRLP(s *rlp.Stream) error
- func (b *Block) DeprecatedTd() *big.Int
- func (b *Block) Difficulty() *big.Int
- func (b *Block) EncodeRLP(w io.Writer) error
- func (b *Block) Extra() []byte
- func (b *Block) Hash() common.Hash
- func (b *Block) HashNoNonce() common.Hash
- func (b *Block) Header() *Header
- func (b *Block) Number() *big.Int
- func (b *Block) NumberU64() uint64
- func (b *Block) ParentHash() common.Hash
- func (b *Block) ProofHash() common.Hash
- func (b *Block) ProofRoot() common.Hash
- func (b *Block) Proofs() ProofStates
- func (b *Block) ReceiptHash() common.Hash
- func (b *Block) Root() common.Hash
- func (b *Block) Size() common.StorageSize
- func (b *Block) String() string
- func (b *Block) Time() *big.Int
- func (b *Block) Transaction(hash common.Hash) *Transaction
- func (b *Block) Transactions() Transactions
- func (b *Block) TxHash() common.Hash
- func (b *Block) WithBody(transactions []*Transaction, proofs []*ProofState) *Block
- func (b *Block) WithSeal(header *Header) *Block
- type BlockBy
- type BlockNonce
- type Blocks
- 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 Body
- type ConfirmMsg
- type DerivableList
- type Header
- type Log
- type LogForStorage
- type ProofConfirm
- type ProofSignature
- type ProofState
- type ProofStates
- type QSHandle
- type QSSigner
- type QueryState
- type QueryStateMsg
- type Receipt
- func (r *Receipt) CalculateHash() ([]byte, error)
- func (r *Receipt) DecodeRLP(s *rlp.Stream) error
- func (r *Receipt) EncodeRLP(w io.Writer) error
- func (r *Receipt) Equals(other merkletree.Content) (bool, error)
- func (r Receipt) MarshalJSON() ([]byte, error)
- func (r *Receipt) String() string
- func (r *Receipt) UnmarshalJSON(input []byte) error
- type ReceiptForStorage
- type Receipts
- type RecoverPubkey
- type ResponseState
- type ResponseStateMsg
- type Signer
- type StorageBlock
- type TaskTh
- type Transaction
- func (tx *Transaction) CalculateHash() ([]byte, error)
- func (tx *Transaction) CheckNonce() bool
- func (tx *Transaction) Data() []byte
- func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
- func (tx *Transaction) EncodeRLP(w io.Writer) error
- func (tx *Transaction) Equals(other merkletree.Content) (bool, error)
- func (tx *Transaction) Hash() common.Hash
- func (tx *Transaction) IsForward() bool
- func (tx *Transaction) MarshalJSON() ([]byte, error)
- func (tx *Transaction) SetForward(forward bool)
- func (tx *Transaction) Size() common.StorageSize
- func (tx *Transaction) String() string
- func (tx *Transaction) UnmarshalJSON(input []byte) error
- type Transactions
- type TransactionsByPayload
- type TxByPayload
- type WorkProof
- type WorkProofMsg
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 = uint(0) // ReceiptStatusSuccessful is the status code of a transaction if execution succeeded. ReceiptStatusSuccessful = uint(1) )
Variables ¶
var ( ErrInvalidChainId = errors.New("invalid chain id for signer") ErrInvalidAsynsinger = errors.New("invalid chain id Asyn Send OK for signer") )
var Bloom9 = bloom9
var (
EmptyRootHash = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
)
var (
ErrInvalidSig = errors.New("invalid transaction v, r, s values")
)
var (
ErrSignCheckFailed = errors.New("recover pubkey failed")
)
Functions ¶
func ASynrecoverPlain ¶
func BloomLookup ¶
func DeriveSha ¶
func DeriveSha(list DerivableList) common.Hash
func DeriveShaWithTree ¶
func DeriveShaWithTree(list DerivableList) common.Hash
Types ¶
type Block ¶
type Block 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 Shx blockchain.
func BuildBlock ¶
func BuildBlock(header *Header, txs []*Transaction, td *big.Int) *Block
func NewBlock ¶
func NewBlock(header *Header, txs []*Transaction, proofs []*ProofState, receipts []*Receipt) *Block
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 TxHash, UncleHash, ReceiptHash and Bloom in header are ignored and set to values derived from the given txs, uncles and receipts.
func NewBlockWithHeader ¶
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 (*Block) DeprecatedTd ¶
DeprecatedTd is an old relic for extracting the TD of a block. It is in the code solely to facilitate upgrading the database from the old format to the new, after which it should be deleted. Do not use!
func (*Block) Difficulty ¶
func (*Block) Hash ¶
Hash returns the keccak256 hash of b's header. The hash is computed on the first call and cached thereafter.
func (*Block) HashNoNonce ¶
func (*Block) ParentHash ¶
func (*Block) Proofs ¶
func (b *Block) Proofs() ProofStates
func (*Block) ReceiptHash ¶
func (*Block) Size ¶
func (b *Block) Size() common.StorageSize
func (*Block) Transaction ¶
func (b *Block) Transaction(hash common.Hash) *Transaction
func (*Block) Transactions ¶
func (b *Block) Transactions() Transactions
func (*Block) WithBody ¶
func (b *Block) WithBody(transactions []*Transaction, proofs []*ProofState) *Block
WithBody returns a new block with the given transaction and uncle contents.
type BlockNonce ¶
type BlockNonce [8]byte
A BlockNonce 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) BlockNonce
EncodeNonce converts the given integer to a block nonce.
func (BlockNonce) MarshalText ¶
func (n BlockNonce) MarshalText() ([]byte, error)
MarshalText encodes n as a hex string with 0x prefix.
func (BlockNonce) Uint64 ¶
func (n BlockNonce) Uint64() uint64
Uint64 returns the integer value of a block nonce.
func (*BlockNonce) UnmarshalText ¶
func (n *BlockNonce) UnmarshalText(input []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
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 (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 Body ¶
type Body struct { Transactions []*Transaction Proofs []*ProofState }
Body is a simple (mutable, non-safe) data container for storing and moving a block's data contents (transactions and uncles) together.
type ConfirmMsg ¶
type ConfirmMsg struct { Confirm ProofConfirm Sign []byte }
func (ConfirmMsg) Hash ¶
func (cfm ConfirmMsg) Hash() common.Hash
type DerivableList ¶
type Header ¶
type Header struct { ParentHash common.Hash `json:"parentHash" gencodec:"required"` Coinbase common.Address `json:"miner" gencodec:"required"` ProofHash common.Hash `json:"proofHash" gencodec:"required"` // latest proofHash of current node. Root common.Hash `json:"stateRoot" gencodec:"required"` TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` ProofRoot common.Hash `json:"proofRoot" gencodec:"required"` // merkle-root of peer's proofState in block body. Difficulty *big.Int `json:"difficulty" gencodec:"required"` Number *big.Int `json:"number" gencodec:"required"` Time *big.Int `json:"timestamp" gencodec:"required"` Extra []byte `json:"extraData" gencodec:"required"` }
Header represents a block header in the Shx blockchain.
func CopyHeader ¶
CopyHeader creates a deep copy of a block header to prevent side effects from modifying a header variable.
func (*Header) Hash ¶
Hash returns the block hash of the header, which is simply the keccak256 hash of its RLP encoding.
func (*Header) HashNoNonce ¶
HashNoNonce returns the hash which is used as input for the proof-of-work search.
func (Header) MarshalJSON ¶
func (*Header) UnmarshalJSON ¶
type Log ¶
type Log struct { // Consensus fields: // address of the contract that generated the event Address common.Address `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"` // 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 uint `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 receipt Index uint `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"` }
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 ProofConfirm ¶
type ProofConfirm struct { Signature ProofSignature Confirm bool }
func (ProofConfirm) Data ¶
func (pc ProofConfirm) Data() []byte
type ProofSignature ¶
type ProofSignature []byte
func (ProofSignature) Hash ¶
func (p ProofSignature) Hash() common.Hash
type ProofState ¶
func (ProofState) CalculateHash ¶
func (p ProofState) CalculateHash() ([]byte, error)
func (ProofState) Equals ¶
func (p ProofState) Equals(other merkletree.Content) (bool, error)
type ProofStates ¶
type ProofStates []*ProofState
func (ProofStates) GetMerkleContent ¶
func (s ProofStates) GetMerkleContent(i int) merkletree.Content
func (ProofStates) GetRlp ¶
func (s ProofStates) GetRlp(i int) []byte
GetRlp implements Rlpable and returns the i'th element of s in rlp
func (ProofStates) Swap ¶
func (s ProofStates) Swap(i, j int)
Swap swaps the i'th and the j'th element in s
type QSHandle ¶
type QSHandle struct {
// contains filtered or unexported fields
}
func QSGetInstance ¶
func QSGetInstance() *QSHandle
func (*QSHandle) ASyncValidateSign ¶
type QSSigner ¶
type QSSigner struct {
// contains filtered or unexported fields
}
EIP155Transaction implements Signer using the EIP155 rules.
func NewQSSigner ¶
func (QSSigner) Hash ¶
func (s QSSigner) Hash(tx *Transaction) common.Hash
Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.
func (QSSigner) SignatureValues ¶
WithSignature returns a new transaction with the given signature. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type QueryState ¶
func (QueryState) Data ¶
func (qs QueryState) Data() []byte
type QueryStateMsg ¶
type QueryStateMsg struct { Qs QueryState Sign []byte }
func (QueryStateMsg) Hash ¶
func (qsm QueryStateMsg) Hash() common.Hash
type Receipt ¶
type Receipt struct { // Consensus fields Status uint `json:"status"` // Not consensus fields //Confirm count by miner node. ConfirmCount uint64 `json:"confirmed" gencodec:"required"` // Implementation fields (don't reorder!) TxHash common.Hash `json:"transactionHash" gencodec:"required"` }
Receipt represents the results of a transaction.
func NewReceipt ¶
NewReceipt creates a barebone transaction receipt, copying the init fields.
func (*Receipt) CalculateHash ¶
func (*Receipt) DecodeRLP ¶
DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt from an RLP stream.
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) MarshalJSON ¶
func (*Receipt) UnmarshalJSON ¶
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.
func (Receipts) GetMerkleContent ¶
func (r Receipts) GetMerkleContent(i int) merkletree.Content
type RecoverPubkey ¶
type RecoverPubkey struct { Tx *Transaction // recover tx's hash Hash []byte Sig []byte // signature }
result for recover pubkey
type ResponseState ¶
func (ResponseState) Data ¶
func (rs ResponseState) Data() []byte
type ResponseStateMsg ¶
type ResponseStateMsg struct { Rs ResponseState Sign []byte }
func (ResponseStateMsg) Hash ¶
func (rsm ResponseStateMsg) Hash() common.Hash
type Signer ¶
type Signer interface { // SignatureValues returns the raw R, S, V values corresponding to the // given signature. SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) // Hash returns the hash to be signed. Hash(tx *Transaction) 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(config *config.ChainConfig) Signer
MakeSigner returns a Signer based on the given chain config and block number.
type StorageBlock ¶
type StorageBlock Block
[deprecated by eth/63] StorageBlock defines the RLP encoding of a Block stored in the state database. The StorageBlock encoding contains fields that would otherwise need to be recomputed.
type Transaction ¶
type Transaction struct { // caches Forward bool // contains filtered or unexported fields }
func NewTransaction ¶
func NewTransaction(data []byte) *Transaction
func SignTx ¶
func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error)
SignTx signs the transaction using the given signer and private key
func (*Transaction) CalculateHash ¶
func (tx *Transaction) CalculateHash() ([]byte, error)
func (*Transaction) CheckNonce ¶
func (tx *Transaction) CheckNonce() bool
func (*Transaction) Data ¶
func (tx *Transaction) Data() []byte
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
DecodeRLP implements rlp.Encoder
func (*Transaction) Equals ¶
func (tx *Transaction) Equals(other merkletree.Content) (bool, error)
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() common.Hash
Hash hashes the RLP encoding of tx. It uniquely identifies the transaction.
func (*Transaction) IsForward ¶
func (tx *Transaction) IsForward() bool
func (*Transaction) MarshalJSON ¶
func (tx *Transaction) MarshalJSON() ([]byte, error)
func (*Transaction) SetForward ¶
func (tx *Transaction) SetForward(forward bool)
func (*Transaction) Size ¶
func (tx *Transaction) Size() common.StorageSize
func (*Transaction) String ¶
func (tx *Transaction) String() string
func (*Transaction) UnmarshalJSON ¶
func (tx *Transaction) UnmarshalJSON(input []byte) error
UnmarshalJSON decodes the web3 RPC transaction format.
type Transactions ¶
type Transactions []*Transaction
Transaction slice type for basic sorting.
func TxDifference ¶
func TxDifference(a, b Transactions) (keep Transactions)
Returns a new set t which is the difference between a to b
func (Transactions) GetMerkleContent ¶
func (s Transactions) GetMerkleContent(i int) merkletree.Content
func (Transactions) GetRlp ¶
func (s Transactions) GetRlp(i int) []byte
GetRlp implements Rlpable and returns the i'th element of s in rlp
func (Transactions) Swap ¶
func (s Transactions) Swap(i, j int)
Swap swaps the i'th and the j'th element in s
type TransactionsByPayload ¶
type TransactionsByPayload struct {
// contains filtered or unexported fields
}
func NewTransactionsByPayload ¶
func NewTransactionsByPayload(txs Transactions) *TransactionsByPayload
NewTransactionsByPayload creates a transaction set that can retrieve payload length sorted transactions.
Note, the input map is reowned so the caller should not interact any more with if after providing it to the constructor.
func (*TransactionsByPayload) Peek ¶
func (t *TransactionsByPayload) Peek() *Transaction
Peek returns the next transaction by price.
func (*TransactionsByPayload) Pop ¶
func (t *TransactionsByPayload) 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 (*TransactionsByPayload) Shift ¶
func (t *TransactionsByPayload) Shift()
Shift replaces the current best head with the next one from the same account.
type TxByPayload ¶
type TxByPayload Transactions
func (TxByPayload) Len ¶
func (s TxByPayload) Len() int
func (TxByPayload) Less ¶
func (s TxByPayload) Less(i, j int) bool
func (*TxByPayload) Pop ¶
func (s *TxByPayload) Pop() interface{}
func (*TxByPayload) Push ¶
func (s *TxByPayload) Push(x interface{})
func (TxByPayload) Swap ¶
func (s TxByPayload) Swap(i, j int)
type WorkProof ¶
type WorkProof struct { Number big.Int Sign ProofSignature Txs Transactions States ProofStates }
type WorkProofMsg ¶
func (WorkProofMsg) Hash ¶
func (wpm WorkProofMsg) Hash() common.Hash