Documentation
¶
Overview ¶
Package types contains data types related to Matrix consensus.
Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php
Index ¶
- Constants
- Variables
- func BatchSender(txser SelfTransactions)
- func BatchSender_self(txs []SelfTransaction, signer Signer, fiter func(SelfTransaction) bool)
- func BloomLookup(bin Bloom, topic bytesBacked) bool
- func CalcUncleHash(uncles []*Header) common.Hash
- func CoinTxHashList(txs []CoinSelfTransaction) (list []common.Hash)
- func DeriveSha(list DerivableList) common.Hash
- func DeriveShaHash(list []common.Hash) common.Hash
- func GetCoinTXRS(txs []SelfTransaction, rxs []*Receipt) ([]CoinSelfTransaction, []CoinReceipts)
- func LogsBloom(logs []*Log) *big.Int
- func Number(b1, b2 *Block) bool
- func RlpEncodeAndHash(x interface{}) (buff []byte, h common.Hash)
- func RlpHash(x interface{}) (h common.Hash)
- func Sender(signer Signer, tx SelfTransaction) (common.Address, error)
- func Sender_self(signer Signer, tx SelfTransaction, waitg *sync.WaitGroup) (common.Address, error)
- func Sender_sub(signer Signer, txChan chan SelfTransaction, waitg *sync.WaitGroup)
- func TxHashList(txs SelfTransactions) (list []common.Hash)
- func TxdataAddresToString(currency string, data *txdata, data1 *txdata1)
- func TxdataStringToAddres(data1 *txdata1, data *txdata)
- type Block
- func (b *Block) Bloom(cointype string) Bloom
- func (b *Block) Body() *Body
- func (b *Block) Coinbase() common.Address
- func (b *Block) Currencies() []CurrencyBlock
- 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) GasLimit() uint64
- func (b *Block) GasUsed() uint64
- func (b *Block) Hash() common.Hash
- func (b *Block) HashNoNonce() common.Hash
- func (b *Block) HashNoSigns() common.Hash
- func (b *Block) HashNoSignsAndNonce() common.Hash
- func (b *Block) Header() *Header
- func (b *Block) IsSuperBlock() bool
- func (b *Block) MixDigest() common.Hash
- func (b *Block) Nonce() uint64
- func (b *Block) Number() *big.Int
- func (b *Block) NumberU64() uint64
- func (b *Block) ParentHash() common.Hash
- func (b *Block) Root() []common.CoinRoot
- func (b *Block) SetCurrencies(currbl []CurrencyBlock)
- func (b *Block) SetHeadNum(num int64)
- func (b *Block) Sharding() []common.Coinbyte
- func (b *Block) SignAccounts() []common.VerifiedSign
- func (b *Block) Size() common.StorageSize
- func (b *Block) Time() *big.Int
- func (b *Block) Transaction(hash common.Hash) SelfTransaction
- func (b *Block) UncleHash() common.Hash
- func (b *Block) Uncles() []*Header
- func (b *Block) Version() []byte
- func (b *Block) VersionSignature() []common.Signature
- func (b *Block) WithBody(cb []CurrencyBlock, uncles []*Header) *Block
- func (b *Block) WithSeal(header *Header) *Block
- type BlockAllSt
- 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 BodyReceipts
- type BodyTransactions
- func (bt *BodyTransactions) CheckHashs() bool
- func (bt *BodyTransactions) DecodeRLP(s *rlp.Stream) error
- func (bt *BodyTransactions) EncodeRLP(w io.Writer) error
- func (bt *BodyTransactions) GetTransactionByIndex(index uint64) SelfTransaction
- func (bt *BodyTransactions) GetTransactions() []SelfTransaction
- type CoinLogs
- type CoinReceipts
- type CoinSelfTransaction
- type CurrencyBlock
- type CurrencyHeader
- type CurrencyReceipts
- type DerivableList
- type EIP155Signer
- type ExtraTo_tr
- type Floodtxdata
- type Header
- func (h *Header) Hash() common.Hash
- func (h *Header) HashNoNonce() common.Hash
- func (h *Header) HashNoSigns() common.Hash
- func (h *Header) HashNoSignsAndNonce() common.Hash
- func (h *Header) IsSuperHeader() bool
- func (h Header) MarshalJSON() ([]byte, error)
- func (h *Header) SignAccounts() []common.VerifiedSign
- func (h *Header) Size() common.StorageSize
- func (h *Header) SuperBlockSeq() uint64
- func (h *Header) UnmarshalJSON(input []byte) error
- type Log
- type LogForStorage
- type Matrix_Extra
- type Matrix_Extra1
- type Receipt
- type ReceiptForStorage
- type Receipts
- type ReceiptsInfo
- type SelfTransaction
- type SelfTransactions
- type Signer
- type SnapSaveInfo
- type StorageBlock
- type Transaction
- func ConvMxtotx(tx_Mx *Transaction_Mx) *Transaction
- func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, ...) *Transaction
- func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, ...) *Transaction
- func NewTransactions(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, ...) *Transaction
- func SetFloodData(floodtx *Floodtxdata) *Transaction
- func (tx *Transaction) AmontFrom() (from common.Address)
- func (tx *Transaction) Call() error
- func (tx *Transaction) ChainId() *big.Int
- func (tx *Transaction) CheckNonce() bool
- func (tx *Transaction) Cost() *big.Int
- func (tx *Transaction) CostALL() *big.Int
- func (tx *Transaction) Data() []byte
- func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
- func (tx *Transaction) EncodeRLP(w io.Writer) error
- func (tx *Transaction) From() common.Address
- func (tx *Transaction) Gas() uint64
- func (tx *Transaction) GasFrom() (from common.Address)
- func (tx *Transaction) GasPrice() *big.Int
- func (tx *Transaction) GetConstructorType() uint16
- func (tx *Transaction) GetCreateTime() uint32
- func (tx *Transaction) GetFromLoad() interface{}
- func (tx *Transaction) GetIsEntrustByCount() bool
- func (tx *Transaction) GetIsEntrustByTime() bool
- func (tx *Transaction) GetIsEntrustGas() bool
- func (tx *Transaction) GetLocalHeight() uint32
- func (tx *Transaction) GetMakeHashfield(chid *big.Int) []interface{}
- func (tx *Transaction) GetMatrixType() byte
- func (tx *Transaction) GetMatrix_EX() []Matrix_Extra
- func (tx *Transaction) GetTxCurrency() string
- func (tx *Transaction) GetTxFrom() (from common.Address, err error)
- func (tx *Transaction) GetTxHashStruct()
- func (tx *Transaction) GetTxN(index int) uint32
- func (tx *Transaction) GetTxNLen() int
- func (tx *Transaction) GetTxR() *big.Int
- func (tx *Transaction) GetTxS() *big.Int
- func (tx *Transaction) GetTxV() *big.Int
- func (tx *Transaction) Hash() common.Hash
- func (tx *Transaction) IsEntrustTx() bool
- func (tx *Transaction) ManTx_UnmarshalJSON(input []byte) error
- func (tx *Transaction) MarshalJSON() ([]byte, error)
- func (tx *Transaction) Nonce() uint64
- func (tx *Transaction) RawSignatureValues() (*big.Int, *big.Int, *big.Int)
- func (tx *Transaction) SetFromLoad(x interface{})
- func (tx *Transaction) SetIsEntrustByCount(b bool)
- func (tx *Transaction) SetIsEntrustByTime(b bool)
- func (tx *Transaction) SetIsEntrustGas(b bool)
- func (tx *Transaction) SetNonce(nc uint64)
- func (tx *Transaction) SetTxCurrency(currency string)
- func (tx *Transaction) SetTxR(r *big.Int)
- func (tx *Transaction) SetTxS(S *big.Int)
- func (tx *Transaction) SetTxV(v *big.Int)
- func (tx *Transaction) Setentrustfrom(x interface{})
- func (tx *Transaction) Size() common.StorageSize
- func (tx *Transaction) To() *common.Address
- func (tx *Transaction) TotalAmount() *big.Int
- func (tx *Transaction) TxType() byte
- func (tx *Transaction) UnmarshalJSON(input []byte) error
- func (tx *Transaction) Value() *big.Int
- func (tx *Transaction) WithSignature(signer Signer, sig []byte) (SelfTransaction, error)
- type TransactionBroad
- func (tx *TransactionBroad) AmontFrom() common.Address
- func (tx *TransactionBroad) Call() error
- func (tx *TransactionBroad) ChainId() *big.Int
- func (tx *TransactionBroad) CheckNonce() bool
- func (tx *TransactionBroad) Data() []byte
- func (tx *TransactionBroad) DecodeRLP(s *rlp.Stream) error
- func (tx *TransactionBroad) EncodeRLP(w io.Writer) error
- func (tx *TransactionBroad) From() common.Address
- func (tx *TransactionBroad) Gas() uint64
- func (tx *TransactionBroad) GasFrom() common.Address
- func (tx *TransactionBroad) GasPrice() *big.Int
- func (tx *TransactionBroad) GetConstructorType() uint16
- func (tx *TransactionBroad) GetCreateTime() uint32
- func (tx *TransactionBroad) GetFromLoad() interface{}
- func (tx *TransactionBroad) GetIsEntrustByCount() bool
- func (tx *TransactionBroad) GetIsEntrustByTime() bool
- func (tx *TransactionBroad) GetIsEntrustGas() bool
- func (tx *TransactionBroad) GetLocalHeight() uint32
- func (tx *TransactionBroad) GetMakeHashfield(chid *big.Int) []interface{}
- func (tx *TransactionBroad) GetMatrixType() byte
- func (tx *TransactionBroad) GetMatrix_EX() []Matrix_Extra
- func (tx *TransactionBroad) GetTxCurrency() string
- func (tx *TransactionBroad) GetTxFrom() (common.Address, error)
- func (tx *TransactionBroad) GetTxHashStruct()
- func (tx *TransactionBroad) GetTxN(index int) uint32
- func (tx *TransactionBroad) GetTxNLen() int
- func (tx *TransactionBroad) GetTxR() *big.Int
- func (tx *TransactionBroad) GetTxS() *big.Int
- func (tx *TransactionBroad) GetTxV() *big.Int
- func (tx *TransactionBroad) Hash() common.Hash
- func (tx *TransactionBroad) IsEntrustTx() bool
- func (tx *TransactionBroad) Nonce() uint64
- func (tx *TransactionBroad) Protected() bool
- func (tx *TransactionBroad) RawSignatureValues() (*big.Int, *big.Int, *big.Int)
- func (tx *TransactionBroad) SetCoinType(typ string)
- func (tx *TransactionBroad) SetFromLoad(x interface{})
- func (tx *TransactionBroad) SetIsEntrustByCount(b bool)
- func (tx *TransactionBroad) SetIsEntrustByTime(b bool)
- func (tx *TransactionBroad) SetIsEntrustGas(b bool)
- func (tx *TransactionBroad) SetNonce(nc uint64)
- func (tx *TransactionBroad) SetTxCurrency(currency string)
- func (tx *TransactionBroad) SetTxR(r *big.Int)
- func (tx *TransactionBroad) SetTxS(S *big.Int)
- func (tx *TransactionBroad) SetTxV(v *big.Int)
- func (tx *TransactionBroad) Setentrustfrom(x interface{})
- func (tx *TransactionBroad) Size() common.StorageSize
- func (tx *TransactionBroad) To() *common.Address
- func (tx *TransactionBroad) TxType() byte
- func (tx *TransactionBroad) Value() *big.Int
- func (tx *TransactionBroad) WithSignature(signer Signer, sig []byte) (SelfTransaction, error)
- type TransactionCall
- type TransactionInfo
- type Transaction_Mx
- type TransactionsByPriceAndNonce
- type TxByNonce
- type TxByPrice
- type Tx_to
- type Tx_to1
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 ( NormalTxIndex byte = iota // NormalPool save normal transaction BroadCastTxIndex // BroadcastPool save broadcast transaction )
Variables ¶
var ( EmptyRootHash = common.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") //DeriveShaHash([]common.Hash{}) EmptyUncleHash = CalcUncleHash(nil) )
var Bloom9 = bloom9
var (
ErrInvalidChainId = errors.New("invalid chain id for signer")
)
var (
ErrInvalidSig = errors.New("invalid transaction v, r, s values")
)
Functions ¶
func BatchSender_self ¶
func BatchSender_self(txs []SelfTransaction, signer Signer, fiter func(SelfTransaction) bool)
func BloomLookup ¶
func CalcUncleHash ¶
func CoinTxHashList ¶
func CoinTxHashList(txs []CoinSelfTransaction) (list []common.Hash)
func DeriveSha ¶
func DeriveSha(list DerivableList) common.Hash
func GetCoinTXRS ¶
func GetCoinTXRS(txs []SelfTransaction, rxs []*Receipt) ([]CoinSelfTransaction, []CoinReceipts)
func RlpEncodeAndHash ¶
func Sender ¶
func Sender(signer Signer, tx SelfTransaction) (common.Address, 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.
func Sender_self ¶
func Sender_sub ¶
func Sender_sub(signer Signer, txChan chan SelfTransaction, waitg *sync.WaitGroup)
func TxHashList ¶
func TxHashList(txs SelfTransactions) (list []common.Hash)
func TxdataAddresToString ¶
func TxdataAddresToString(currency string, data *txdata, data1 *txdata1)
func TxdataStringToAddres ¶
func TxdataStringToAddres(data1 *txdata1, data *txdata)
Types ¶
type Block ¶
type Block struct { // These fields are used by package man to track // inter-peer block relay. ReceivedAt time.Time ReceivedFrom interface{} // contains filtered or unexported fields }
if RPC Block: Block header uncles Currencies.Transactions Tx and TxReceipts : []Currencies.Transactions,[]Currencies.Receipts Save Raw Body []Currencies.Transactions Save Receipts []Currencies.Receipts Block represents an entire block in the Matrix blockchain.
func NewBlock ¶
func NewBlock(header *Header, currencyBlocks []CurrencyBlock, uncles []*Header) *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 NewBlockWithTxs ¶
func NewBlockWithTxs(header *Header, currencyBlocks []CurrencyBlock) *Block
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) Currencies ¶
func (b *Block) Currencies() []CurrencyBlock
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) HashNoSigns ¶
func (*Block) HashNoSignsAndNonce ¶
func (*Block) IsSuperBlock ¶
func (*Block) ParentHash ¶
func (*Block) SetCurrencies ¶
func (b *Block) SetCurrencies(currbl []CurrencyBlock)
func (*Block) SignAccounts ¶
func (b *Block) SignAccounts() []common.VerifiedSign
func (*Block) Size ¶
func (b *Block) 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 (*Block) Transaction ¶
func (b *Block) Transaction(hash common.Hash) SelfTransaction
func (*Block) VersionSignature ¶
type BlockAllSt ¶
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 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 Body ¶
type Body struct { CurrencyBody []CurrencyBlock Uncles []*Header }
Body is a simple (mutable, non-safe) data container for storing and moving a block's data contents (transactions and uncles) together.
type BodyReceipts ¶
type BodyReceipts struct { Sharding []uint // if complete block sharding = [] Rs Receipts //complete transactions RsHashs []common.Hash ReceiptsInfos []ReceiptsInfo //complete transactions }
func SetReceipts ¶
func SetReceipts(Receiptser []*Receipt, hashlist []common.Hash, shadings []uint) BodyReceipts
func (*BodyReceipts) CheckRecptHashs ¶
func (bt *BodyReceipts) CheckRecptHashs() bool
func (*BodyReceipts) GetAReceiptsByIndex ¶
func (bt *BodyReceipts) GetAReceiptsByIndex(index uint64) *Receipt
func (*BodyReceipts) GetReceipts ¶
func (br *BodyReceipts) GetReceipts() Receipts
type BodyTransactions ¶
type BodyTransactions struct { Sharding []uint // if complete block sharding = [] Transactions []SelfTransaction //complete transactions TxHashs []common.Hash //所有交易的hash TransactionInfos []TransactionInfo //sharding transactions }
1. Complete Block transactions = []SelfTransactio 2. Sharding Block transactions = []TxInfo
func SetTransactions ¶
func SetTransactions(txser SelfTransactions, hashlist []common.Hash, shadings []uint) BodyTransactions
func (*BodyTransactions) CheckHashs ¶
func (bt *BodyTransactions) CheckHashs() bool
func (*BodyTransactions) GetTransactionByIndex ¶
func (bt *BodyTransactions) GetTransactionByIndex(index uint64) SelfTransaction
func (*BodyTransactions) GetTransactions ¶
func (bt *BodyTransactions) GetTransactions() []SelfTransaction
type CoinReceipts ¶
type CoinSelfTransaction ¶
type CoinSelfTransaction struct { CoinType string Txser SelfTransactions }
func GetCoinTX ¶
func GetCoinTX(txs []SelfTransaction) []CoinSelfTransaction
type CurrencyBlock ¶
type CurrencyBlock struct { CurrencyName string Header CurrencyHeader Transactions BodyTransactions Receipts BodyReceipts }
币种block 1 Validator : 2 Miner : return len([]Sharding) == 0 discard tx Call Txs : input CurrencyBlock
func MakeCurencyBlock ¶
func MakeCurencyBlock(txser []CoinSelfTransaction, rece []CoinReceipts, shardings []uint) []CurrencyBlock
type CurrencyHeader ¶
type CurrencyReceipts ¶
type CurrencyReceipts struct { Currency string StorageReceipts []*ReceiptForStorage }
type DerivableList ¶
type EIP155Signer ¶
type EIP155Signer struct {
// contains filtered or unexported fields
}
EIP155Transaction implements Signer using the EIP155 rules.
func NewEIP155Signer ¶
func NewEIP155Signer(chainId *big.Int) EIP155Signer
func (EIP155Signer) Equal ¶
func (s EIP155Signer) Equal(s2 Signer) bool
func (EIP155Signer) Hash ¶
func (s EIP155Signer) Hash(txer SelfTransaction) 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 SelfTransaction) (common.Address, error)
func (EIP155Signer) SignatureValues ¶
func (s EIP155Signer) SignatureValues(tx SelfTransaction, sig []byte) (R, S, V *big.Int, err error)
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 ExtraTo_tr ¶
type Floodtxdata ¶
type Floodtxdata struct { AccountNonce uint64 `json:"nonce" gencodec:"required"` Price *big.Int `json:"gasPrice" gencodec:"required"` GasLimit uint64 `json:"gas" gencodec:"required"` Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation Amount *big.Int `json:"value" gencodec:"required"` Payload []byte `json:"input" gencodec:"required"` Currency string // Signature values V *big.Int `json:"v" gencodec:"required"` R *big.Int `json:"r" gencodec:"required"` TxEnterType byte `json:"TxEnterType" gencodec:"required"` //是否是委托 IsEntrustTx byte `json:"IsEntrustTx" gencodec:"required"` //是否是委托 CommitTime uint64 `json:"CommitTime" gencodec:"required"` //创建交易时间 Extra []Matrix_Extra ` rlp:"tail"` }
用于洪泛(传输)
func GetFloodData ¶
func GetFloodData(tx *Transaction) *Floodtxdata
type Header ¶
type Header struct { ParentHash common.Hash `json:"parentHash" gencodec:"required"` UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"` Leader common.Address `json:"leader" gencodec:"required"` Coinbase common.Address `json:"miner" gencodec:"required"` Roots []common.CoinRoot `json:"stateRoot" gencodec:"required"` Sharding []common.Coinbyte `json:"sharding" gencodec:"required"` Difficulty *big.Int `json:"difficulty" gencodec:"required"` Number *big.Int `json:"number" gencodec:"required"` GasLimit uint64 `json:"gasLimit" gencodec:"required"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` Time *big.Int `json:"timestamp" gencodec:"required"` Elect []common.Elect `json:"elect" gencodec:"required"` NetTopology common.NetTopology `json:"nettopology" gencodec:"required"` Signatures []common.Signature `json:"signatures" gencodec:"required"` Extra []byte `json:"extraData" gencodec:"required"` MixDigest common.Hash `json:"mixHash" gencodec:"required"` Nonce BlockNonce `json:"nonce" gencodec:"required"` Version []byte `json:"version" gencodec:"required"` VersionSignatures []common.Signature `json:"versionSignatures" gencodec:"required"` VrfValue []byte `json:"vrfvalue" gencodec:"required"` }
Header represents a block header in the Matrix 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) HashNoSigns ¶
func (*Header) HashNoSignsAndNonce ¶
func (*Header) IsSuperHeader ¶
func (Header) MarshalJSON ¶
func (*Header) SignAccounts ¶
func (h *Header) SignAccounts() []common.VerifiedSign
func (*Header) Size ¶
func (h *Header) 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.
func (*Header) SuperBlockSeq ¶
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.
func (Log) MarshalJSON ¶
func (*Log) UnmarshalJSON ¶
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 Matrix_Extra ¶
type Matrix_Extra1 ¶
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 common.Address `json:"contractAddress"` 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) 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 ¶
MarshalJSON marshals as JSON.
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.
func (*Receipt) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.
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 ReceiptsInfo ¶
type SelfTransaction ¶
type SelfTransaction interface { TxType() byte Data() []byte Gas() uint64 GasPrice() *big.Int Value() *big.Int Nonce() uint64 CheckNonce() bool GetMatrix_EX() []Matrix_Extra From() common.Address GetTxFrom() (common.Address, error) SetNonce(nc uint64) GetTxS() *big.Int GetTxR() *big.Int GetTxV() *big.Int SetTxS(S *big.Int) SetTxV(v *big.Int) SetTxR(r *big.Int) To() *common.Address Hash() common.Hash Size() common.StorageSize GetFromLoad() interface{} SetFromLoad(x interface{}) ChainId() *big.Int WithSignature(signer Signer, sig []byte) (SelfTransaction, error) GetTxNLen() int GetTxN(index int) uint32 RawSignatureValues() (*big.Int, *big.Int, *big.Int) //Protected() bool GetConstructorType() uint16 GasFrom() common.Address AmontFrom() common.Address GetMatrixType() byte Setentrustfrom(x interface{}) IsEntrustTx() bool SetTxCurrency(currency string) GetTxCurrency() string GetCreateTime() uint32 GetLocalHeight() uint32 GetIsEntrustGas() bool GetIsEntrustByTime() bool GetMakeHashfield(chid *big.Int) []interface{} SetIsEntrustGas(b bool) SetIsEntrustByTime(b bool) GetIsEntrustByCount() bool SetIsEntrustByCount(b bool) }
func GetTX ¶
func GetTX(ctx []CoinSelfTransaction) []SelfTransaction
func SetMxToTransaction ¶
func SetMxToTransaction(txm *Transaction_Mx) (txer SelfTransaction)
func SignTx ¶
func SignTx(tx SelfTransaction, s Signer, prv *ecdsa.PrivateKey) (SelfTransaction, error)
SignTx signs the transaction using the given signer and private key
type SelfTransactions ¶
type SelfTransactions []SelfTransaction
Transactions is a Transaction slice type for basic sorting.
func TxDifference ¶
func TxDifference(a, b SelfTransactions) (keep SelfTransactions)
TxDifference returns a new set t which is the difference between a to b.
func (SelfTransactions) GetRlp ¶
func (s SelfTransactions) GetRlp(i int) []byte
GetRlp implements Rlpable and returns the i'th element of s in rlp.
func (SelfTransactions) Swap ¶
func (s SelfTransactions) Swap(i, j int)
Swap swaps the i'th and the j'th element in s.
type Signer ¶
type Signer interface { // Sender returns the sender address of the transaction. Sender(tx SelfTransaction) (common.Address, error) // SignatureValues returns the raw R, S, V values corresponding to the // given signature. SignatureValues(tx SelfTransaction, sig []byte) (r, s, v *big.Int, err error) // Hash returns the hash to be signed. Hash(tx SelfTransaction) 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 *params.ChainConfig, blockNumber *big.Int) Signer
MakeSigner returns a Signer based on the given chain config and block number.
type SnapSaveInfo ¶
type StorageBlock ¶
type StorageBlock Block
[deprecated by man/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 { Currency string //币种 // by N []uint32 IsEntrustGas bool IsEntrustByTime bool //是否是按时间委托 IsEntrustByCount bool //是否按次数委托 // contains filtered or unexported fields }
func ConvMxtotx ¶
func ConvMxtotx(tx_Mx *Transaction_Mx) *Transaction
func NewContractCreation ¶
func NewTransaction ¶
func NewTransactions ¶
func SetFloodData ¶
func SetFloodData(floodtx *Floodtxdata) *Transaction
func (*Transaction) AmontFrom ¶
func (tx *Transaction) AmontFrom() (from common.Address)
func (*Transaction) Call ¶
func (tx *Transaction) Call() error
func (*Transaction) ChainId ¶
func (tx *Transaction) ChainId() *big.Int
ChainId returns which chain id this transaction was signed for (if at all)
func (*Transaction) CheckNonce ¶
func (tx *Transaction) CheckNonce() bool
func (*Transaction) Cost ¶
func (tx *Transaction) Cost() *big.Int
Cost returns amount + gasprice * gaslimit.
func (*Transaction) CostALL ¶
func (tx *Transaction) CostALL() *big.Int
// Cost returns amount + gasprice * gaslimit.
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
EncodeRLP implements rlp.Encoder
func (*Transaction) Gas ¶
func (tx *Transaction) Gas() uint64
func (*Transaction) GasFrom ¶
func (tx *Transaction) GasFrom() (from common.Address)
func (*Transaction) GasPrice ¶
func (tx *Transaction) GasPrice() *big.Int
func (*Transaction) GetConstructorType ¶
func (tx *Transaction) GetConstructorType() uint16
func (*Transaction) GetCreateTime ¶
func (tx *Transaction) GetCreateTime() uint32
func (*Transaction) GetFromLoad ¶
func (tx *Transaction) GetFromLoad() interface{}
func (*Transaction) GetIsEntrustByCount ¶
func (tx *Transaction) GetIsEntrustByCount() bool
func (*Transaction) GetIsEntrustByTime ¶
func (tx *Transaction) GetIsEntrustByTime() bool
func (*Transaction) GetIsEntrustGas ¶
func (tx *Transaction) GetIsEntrustGas() bool
func (*Transaction) GetLocalHeight ¶
func (tx *Transaction) GetLocalHeight() uint32
func (*Transaction) GetMakeHashfield ¶
func (tx *Transaction) GetMakeHashfield(chid *big.Int) []interface{}
func (*Transaction) GetMatrixType ¶
func (tx *Transaction) GetMatrixType() byte
func (*Transaction) GetMatrix_EX ¶
func (tx *Transaction) GetMatrix_EX() []Matrix_Extra
func (*Transaction) GetTxCurrency ¶
func (tx *Transaction) GetTxCurrency() string
func (*Transaction) GetTxHashStruct ¶
func (tx *Transaction) GetTxHashStruct()
func (*Transaction) GetTxN ¶
func (tx *Transaction) GetTxN(index int) uint32
func (*Transaction) GetTxNLen ¶
func (tx *Transaction) GetTxNLen() int
func (*Transaction) GetTxR ¶
func (tx *Transaction) GetTxR() *big.Int
func (*Transaction) GetTxS ¶
func (tx *Transaction) GetTxS() *big.Int
func (*Transaction) GetTxV ¶
func (tx *Transaction) GetTxV() *big.Int
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() common.Hash
Hash hashes the RLP encoding of tx. It uniquely identifies the transaction.
func (*Transaction) IsEntrustTx ¶
func (tx *Transaction) IsEntrustTx() bool
func (*Transaction) ManTx_UnmarshalJSON ¶
func (tx *Transaction) ManTx_UnmarshalJSON(input []byte) error
func (*Transaction) MarshalJSON ¶
func (tx *Transaction) MarshalJSON() ([]byte, error)
MarshalJSON encodes the web3 RPC transaction format.
func (*Transaction) Nonce ¶
func (tx *Transaction) Nonce() uint64
func (*Transaction) RawSignatureValues ¶
func (*Transaction) SetFromLoad ¶
func (tx *Transaction) SetFromLoad(x interface{})
func (*Transaction) SetIsEntrustByCount ¶
func (tx *Transaction) SetIsEntrustByCount(b bool)
func (*Transaction) SetIsEntrustByTime ¶
func (tx *Transaction) SetIsEntrustByTime(b bool)
func (*Transaction) SetIsEntrustGas ¶
func (tx *Transaction) SetIsEntrustGas(b bool)
func (*Transaction) SetTxCurrency ¶
func (tx *Transaction) SetTxCurrency(currency string)
func (*Transaction) SetTxR ¶
func (tx *Transaction) SetTxR(r *big.Int)
func (*Transaction) SetTxS ¶
func (tx *Transaction) SetTxS(S *big.Int)
func (*Transaction) SetTxV ¶
func (tx *Transaction) SetTxV(v *big.Int)
func (*Transaction) Setentrustfrom ¶
func (tx *Transaction) Setentrustfrom(x interface{})
func (*Transaction) Size ¶
func (tx *Transaction) 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 (*Transaction) To ¶
func (tx *Transaction) To() *common.Address
To returns the recipient address of the transaction. It returns nil if the transaction is a contract creation.
func (*Transaction) TotalAmount ¶
func (tx *Transaction) TotalAmount() *big.Int
func (*Transaction) TxType ¶
func (tx *Transaction) TxType() byte
func (*Transaction) UnmarshalJSON ¶
func (tx *Transaction) UnmarshalJSON(input []byte) error
UnmarshalJSON decodes the web3 RPC transaction format.
func (*Transaction) Value ¶
func (tx *Transaction) Value() *big.Int
func (*Transaction) WithSignature ¶
func (tx *Transaction) WithSignature(signer Signer, sig []byte) (SelfTransaction, 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 TransactionBroad ¶
type TransactionBroad struct {
// contains filtered or unexported fields
}
func NewBroadCastTransaction ¶
func NewBroadCastTransaction(txType byte, data []byte) *TransactionBroad
func SetTransactionMx ¶
func SetTransactionMx(tx_Mx *Transaction_Mx) *TransactionBroad
//
func (tx *TransactionBroad) SetTransactionMx(tx_Mx *Transaction_Mx)(txer SelfTransaction ){ if tx_Mx == nil{ return nil } tx.data.AccountNonce=tx_Mx.Data.AccountNonce tx.data.Price=tx_Mx.Data.Price tx.data.GasLimit=tx_Mx.Data.GasLimit tx.data.Recipient=tx_Mx.Data.Recipient tx.data.Amount=tx_Mx.Data.Amount tx.data.Payload=tx_Mx.Data.Payload // Signature values tx.data.V=tx_Mx.Data.V tx.data.R=tx_Mx.Data.R tx.data.S=tx_Mx.Data.S tx.data.TxEnterType=BroadCastTxIndex tx.data.Extra=tx_Mx.Data.Extra mx := Matrix_Extra{ TxType: tx_Mx.TxType_Mx, } tx.data.Extra = append(tx.data.Extra, mx) txa := &TransactionBroad{data: tx.data} txer = txa return }
//
func (tx *TransactionBroad)GetTransactionMx(stx SelfTransaction) *Transaction_Mx { btx,ok:=stx.(*TransactionBroad) if !ok { return nil } tx_Mx := &Transaction_Mx{} tx_Mx.Data.AccountNonce = btx.data.AccountNonce tx_Mx.Data.Price = btx.data.Price tx_Mx.Data.GasLimit = btx.data.GasLimit tx_Mx.Data.Recipient = btx.data.Recipient tx_Mx.Data.Amount = btx.data.Amount tx_Mx.Data.Payload = btx.data.Payload // Signature values tx_Mx.Data.V = btx.data.V tx_Mx.Data.R = btx.data.R tx_Mx.Data.S = btx.data.S tx_Mx.Data.Extra = btx.data.Extra tx_Mx.Data.TxEnterType = btx.data.TxEnterType if len(btx.data.Extra) > 0 { tx_Mx.TxType_Mx = btx.data.Extra[0].TxType } return tx_Mx }
func (*TransactionBroad) AmontFrom ¶
func (tx *TransactionBroad) AmontFrom() common.Address
func (*TransactionBroad) Call ¶
func (tx *TransactionBroad) Call() error
func (*TransactionBroad) ChainId ¶
func (tx *TransactionBroad) ChainId() *big.Int
func (*TransactionBroad) CheckNonce ¶
func (tx *TransactionBroad) CheckNonce() bool
func (*TransactionBroad) Data ¶
func (tx *TransactionBroad) Data() []byte
func (*TransactionBroad) DecodeRLP ¶
func (tx *TransactionBroad) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder
func (*TransactionBroad) EncodeRLP ¶
func (tx *TransactionBroad) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder
func (*TransactionBroad) From ¶
func (tx *TransactionBroad) From() common.Address
func (*TransactionBroad) Gas ¶
func (tx *TransactionBroad) Gas() uint64
func (*TransactionBroad) GasFrom ¶
func (tx *TransactionBroad) GasFrom() common.Address
func (*TransactionBroad) GasPrice ¶
func (tx *TransactionBroad) GasPrice() *big.Int
func (*TransactionBroad) GetConstructorType ¶
func (tx *TransactionBroad) GetConstructorType() uint16
func (*TransactionBroad) GetCreateTime ¶
func (tx *TransactionBroad) GetCreateTime() uint32
func (*TransactionBroad) GetFromLoad ¶
func (tx *TransactionBroad) GetFromLoad() interface{}
func (*TransactionBroad) GetIsEntrustByCount ¶
func (tx *TransactionBroad) GetIsEntrustByCount() bool
func (*TransactionBroad) GetIsEntrustByTime ¶
func (tx *TransactionBroad) GetIsEntrustByTime() bool
func (*TransactionBroad) GetIsEntrustGas ¶
func (tx *TransactionBroad) GetIsEntrustGas() bool
func (*TransactionBroad) GetLocalHeight ¶
func (tx *TransactionBroad) GetLocalHeight() uint32
func (*TransactionBroad) GetMakeHashfield ¶
func (tx *TransactionBroad) GetMakeHashfield(chid *big.Int) []interface{}
func (*TransactionBroad) GetMatrixType ¶
func (tx *TransactionBroad) GetMatrixType() byte
func (*TransactionBroad) GetMatrix_EX ¶
func (tx *TransactionBroad) GetMatrix_EX() []Matrix_Extra
func (*TransactionBroad) GetTxCurrency ¶
func (tx *TransactionBroad) GetTxCurrency() string
func (*TransactionBroad) GetTxFrom ¶
func (tx *TransactionBroad) GetTxFrom() (common.Address, error)
func (*TransactionBroad) GetTxHashStruct ¶
func (tx *TransactionBroad) GetTxHashStruct()
func (*TransactionBroad) GetTxN ¶
func (tx *TransactionBroad) GetTxN(index int) uint32
func (*TransactionBroad) GetTxNLen ¶
func (tx *TransactionBroad) GetTxNLen() int
func (*TransactionBroad) GetTxR ¶
func (tx *TransactionBroad) GetTxR() *big.Int
func (*TransactionBroad) GetTxS ¶
func (tx *TransactionBroad) GetTxS() *big.Int
func (*TransactionBroad) GetTxV ¶
func (tx *TransactionBroad) GetTxV() *big.Int
func (*TransactionBroad) Hash ¶
func (tx *TransactionBroad) Hash() common.Hash
Hash hashes the RLP encoding of tx. It uniquely identifies the transaction.
func (*TransactionBroad) IsEntrustTx ¶
func (tx *TransactionBroad) IsEntrustTx() bool
func (*TransactionBroad) Nonce ¶
func (tx *TransactionBroad) Nonce() uint64
func (*TransactionBroad) Protected ¶
func (tx *TransactionBroad) Protected() bool
func (*TransactionBroad) RawSignatureValues ¶
func (*TransactionBroad) SetCoinType ¶
func (tx *TransactionBroad) SetCoinType(typ string)
func (*TransactionBroad) SetFromLoad ¶
func (tx *TransactionBroad) SetFromLoad(x interface{})
func (*TransactionBroad) SetIsEntrustByCount ¶
func (tx *TransactionBroad) SetIsEntrustByCount(b bool)
func (*TransactionBroad) SetIsEntrustByTime ¶
func (tx *TransactionBroad) SetIsEntrustByTime(b bool)
func (*TransactionBroad) SetIsEntrustGas ¶
func (tx *TransactionBroad) SetIsEntrustGas(b bool)
func (*TransactionBroad) SetTxCurrency ¶
func (tx *TransactionBroad) SetTxCurrency(currency string)
func (*TransactionBroad) SetTxR ¶
func (tx *TransactionBroad) SetTxR(r *big.Int)
func (*TransactionBroad) SetTxS ¶
func (tx *TransactionBroad) SetTxS(S *big.Int)
func (*TransactionBroad) SetTxV ¶
func (tx *TransactionBroad) SetTxV(v *big.Int)
func (*TransactionBroad) Setentrustfrom ¶
func (tx *TransactionBroad) Setentrustfrom(x interface{})
func (*TransactionBroad) Size ¶
func (tx *TransactionBroad) Size() common.StorageSize
func (*TransactionBroad) To ¶
func (tx *TransactionBroad) To() *common.Address
func (*TransactionBroad) TxType ¶
func (tx *TransactionBroad) TxType() byte
func (*TransactionBroad) Value ¶
func (tx *TransactionBroad) Value() *big.Int
func (*TransactionBroad) WithSignature ¶
func (tx *TransactionBroad) WithSignature(signer Signer, sig []byte) (SelfTransaction, 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 TransactionCall ¶
type TransactionCall struct {
*Transaction
}
func (*TransactionCall) CheckNonce ¶
func (tc *TransactionCall) CheckNonce() bool
type TransactionInfo ¶
type TransactionInfo struct { Index uint64 Tx SelfTransaction }
type Transaction_Mx ¶
type Transaction_Mx struct { Data txdata Currency string TxType_Mx byte LockHeight uint64 `json:"lockHeight" gencodec:"required"` ExtraTo []Tx_to `json:"extra_to" gencodec:"required"` }
func ConvTxtoMxtx ¶
func ConvTxtoMxtx(txer SelfTransaction) *Transaction_Mx
func GetTransactionMx ¶
func GetTransactionMx(stx SelfTransaction) *Transaction_Mx
func SetTransactionToMx ¶
func SetTransactionToMx(txer SelfTransaction) (txm *Transaction_Mx)
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[common.Address]SelfTransactions) *TransactionsByPriceAndNonce
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() SelfTransaction
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()
Shift replaces the current best head with the next one from the same account.
type TxByNonce ¶
type TxByNonce []SelfTransaction
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 SelfTransactions
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.