Documentation
¶
Index ¶
- Constants
- Variables
- func AddressToString(address Address) string
- func CalcMaxFaultyNodes(s Validators) int
- func CalculateHeaderHash(h *Header) ([]byte, error)
- func EncodeBigInt(b *big.Int) *string
- func EncodeBytes(b []byte) *string
- func EncodeUint64(b uint64) *string
- func MarshalRLPTo(obj marshalRLPFunc, dst []byte) []byte
- func ParseBytes(val *string) ([]byte, error)
- func ParseInt64orHex(val *string) (int64, error)
- func ParseUint256orHex(val *string) (*big.Int, error)
- func ParseUint64orHex(val *string) (uint64, error)
- func PutIbftExtraValidators(h *Header, validators []Address)
- func UnmarshalRlp(obj unmarshalRLPFunc, input []byte) error
- type Address
- func (a Address) Bytes() []byte
- func (a Address) ImplementsGraphQLType(name string) bool
- func (a Address) MarshalText() ([]byte, error)
- func (a Address) Ptr() *Address
- func (a *Address) Scan(src interface{}) error
- func (a Address) String() string
- func (a *Address) UnmarshalGraphQL(input interface{}) error
- func (a *Address) UnmarshalText(input []byte) error
- func (a Address) Value() (driver.Value, error)
- type Block
- func (b *Block) Body() *Body
- func (b *Block) Compare(other pq.Item) int
- func (b *Block) Hash() Hash
- func (b *Block) MarshalRLP() []byte
- func (b *Block) MarshalRLPTo(dst []byte) []byte
- func (b *Block) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value
- func (b *Block) Number() uint64
- func (b *Block) ParentHash() Hash
- func (b *Block) Size() uint64
- func (b *Block) String() string
- func (b *Block) UnmarshalRLP(input []byte) error
- func (b *Block) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error
- func (b *Block) WithSeal(header *Header) *Block
- type Bloom
- type Body
- type Hash
- func (h Hash) Bytes() []byte
- func (h Hash) ImplementsGraphQLType(name string) bool
- func (h Hash) MarshalText() ([]byte, error)
- func (h *Hash) Scan(src interface{}) error
- func (h Hash) String() string
- func (h *Hash) UnmarshalGraphQL(input interface{}) error
- func (h *Hash) UnmarshalText(input []byte) error
- func (h Hash) Value() (driver.Value, error)
- type Header
- func (h *Header) ComputeHash() *Header
- func (h *Header) Copy() *Header
- func (h *Header) Equal(hh *Header) bool
- func (h *Header) HasBody() bool
- func (h *Header) HasReceipts() bool
- func (h *Header) MarshalRLP() []byte
- func (h *Header) MarshalRLPTo(dst []byte) []byte
- func (h *Header) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value
- func (h *Header) SetNonce(i uint64)
- func (h *Header) UnmarshalRLP(input []byte) error
- func (h *Header) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error
- type IstanbulExtra
- type Log
- type Nonce
- type PoolTxByNonce
- type RLPMarshaler
- type RLPStoreMarshaler
- type RLPStoreUnmarshaler
- type RLPUnmarshaler
- type Receipt
- func (r *Receipt) MarshalLogsWith(a *fastrlp.Arena) *fastrlp.Value
- func (r *Receipt) MarshalRLP() []byte
- func (r *Receipt) MarshalRLPTo(dst []byte) []byte
- func (r *Receipt) MarshalRLPWith(a *fastrlp.Arena) *fastrlp.Value
- func (r *Receipt) MarshalStoreRLPTo(dst []byte) []byte
- func (r *Receipt) MarshalStoreRLPWith(a *fastrlp.Arena) *fastrlp.Value
- func (r *Receipt) SetContractAddress(contractAddress Address)
- func (r *Receipt) SetStatus(s ReceiptStatus)
- func (r *Receipt) UnmarshalRLP(input []byte) error
- func (r *Receipt) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error
- func (r *Receipt) UnmarshalStoreRLP(input []byte) error
- func (r *Receipt) UnmarshalStoreRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error
- type ReceiptStatus
- type Receipts
- func (r Receipts) MarshalRLPTo(dst []byte) []byte
- func (r *Receipts) MarshalRLPWith(a *fastrlp.Arena) *fastrlp.Value
- func (r Receipts) MarshalStoreRLPTo(dst []byte) []byte
- func (r *Receipts) MarshalStoreRLPWith(a *fastrlp.Arena) *fastrlp.Value
- func (r *Receipts) UnmarshalRLP(input []byte) error
- func (r *Receipts) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error
- func (r *Receipts) UnmarshalStoreRLP(input []byte) error
- func (r *Receipts) UnmarshalStoreRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error
- type Snapshot
- type Transaction
- func (t *Transaction) Copy() *Transaction
- func (t *Transaction) Cost() *big.Int
- func (t *Transaction) ExceedsBlockGasLimit(blockGasLimit uint64) bool
- func (t *Transaction) Hash() Hash
- func (t *Transaction) IsContractCreation() bool
- func (t *Transaction) IsUnderpriced(priceLimit uint64) bool
- func (t *Transaction) MarshalRLP() []byte
- func (t *Transaction) MarshalRLPTo(dst []byte) []byte
- func (t *Transaction) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value
- func (t *Transaction) MarshalStoreRLPTo(dst []byte) []byte
- func (t *Transaction) MarshalStoreRLPWith(a *fastrlp.Arena) *fastrlp.Value
- func (t *Transaction) Size() uint64
- func (t *Transaction) UnmarshalRLP(input []byte) error
- func (t *Transaction) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error
- func (t *Transaction) UnmarshalStoreRLP(input []byte) error
- func (t *Transaction) UnmarshalStoreRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error
- type TransactionsByPriceAndNonce
- type TxByPriceAndTime
- type Validators
- func (v *Validators) Add(addr Address)
- func (v *Validators) CalcProposer(round uint64, lastProposer Address) Address
- func (v *Validators) Del(addr Address)
- func (v *Validators) Equal(vv *Validators) bool
- func (v *Validators) Includes(addr Address) bool
- func (v *Validators) Index(addr Address) int
- func (v *Validators) Len() int
- type Vote
Constants ¶
const (
AddressLength = 20
)
const BloomByteLength = 256
const (
HashLength = 32
)
const IstanbulExtraVanity = 32
Variables ¶
var ( // ZeroHash is all zero hash ZeroHash = Hash{} // EmptyRootHash is the root when there are no transactions EmptyRootHash = StringToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") // EmptyUncleHash is the root when there are no uncles EmptyUncleHash = StringToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347") )
var (
HeaderHash func(h *Header) Hash
)
var ZeroAddress = Address{}
Functions ¶
func AddressToString ¶
func CalcMaxFaultyNodes ¶
func CalcMaxFaultyNodes(s Validators) int
CalcMaxFaultyNodes returns the maximum number of allowed faulty nodes (F), based on the current validator set
func CalculateHeaderHash ¶
func EncodeBigInt ¶
func EncodeBytes ¶
func EncodeUint64 ¶
func MarshalRLPTo ¶
func ParseBytes ¶
func ParseInt64orHex ¶
func ParseUint64orHex ¶
func PutIbftExtraValidators ¶
PutIbftExtraValidators is a helper method that adds validators to the extra field in the header
func UnmarshalRlp ¶
Types ¶
type Address ¶
type Address [AddressLength]byte
func BytesToAddress ¶
func StringToAddress ¶
func (Address) ImplementsGraphQLType ¶
ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.
func (Address) MarshalText ¶
func (*Address) UnmarshalGraphQL ¶
UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (*Address) UnmarshalText ¶
UnmarshalText parses an address in hex syntax.
type Block ¶
type Block struct {
Header *Header
Transactions []*Transaction
Uncles []*Header
// contains filtered or unexported fields
}
func (*Block) MarshalRLP ¶
func (*Block) MarshalRLPTo ¶
func (*Block) ParentHash ¶
func (*Block) UnmarshalRLP ¶
func (*Block) UnmarshalRLPFrom ¶
type Bloom ¶
type Bloom [BloomByteLength]byte
func CreateBloom ¶
CreateBloom creates a new bloom filter from a set of receipts
func (*Bloom) IsLogInBloom ¶
IsLogInBloom checks if the log has a possible presence in the bloom filter
func (Bloom) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*Bloom) UnmarshalText ¶
type Body ¶
type Body struct {
Transactions []*Transaction
Uncles []*Header
}
func (*Body) MarshalRLPTo ¶
func (*Body) UnmarshalRLP ¶
type Hash ¶
type Hash [HashLength]byte
func BytesToHash ¶
func StringToHash ¶
func (Hash) ImplementsGraphQLType ¶
ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.
func (Hash) MarshalText ¶
func (*Hash) UnmarshalGraphQL ¶
UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (*Hash) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type Header ¶
type Header struct {
ParentHash Hash
Sha3Uncles Hash
Miner Address
StateRoot Hash
TxRoot Hash
ReceiptsRoot Hash
LogsBloom Bloom
Difficulty uint64
Number uint64
GasLimit uint64
GasUsed uint64
Timestamp uint64
ExtraData []byte
MixHash Hash
Nonce Nonce
Hash Hash
}
Header represents a block header in the Ethereum blockchain.
func (*Header) ComputeHash ¶
ComputeHash computes the hash of the header
func (*Header) HasReceipts ¶
func (*Header) MarshalRLP ¶
func (*Header) MarshalRLPTo ¶
func (*Header) MarshalRLPWith ¶
MarshalRLPWith marshals the header to RLP with a specific fastrlp.Arena
func (*Header) UnmarshalRLP ¶
type IstanbulExtra ¶
IstanbulExtra defines the structure of the extra field for Istanbul
func GetIbftExtra ¶
func GetIbftExtra(h *Header) (*IstanbulExtra, error)
GetIbftExtra returns the istanbul extra data field from the passed in header
func (*IstanbulExtra) MarshalRLPTo ¶
func (i *IstanbulExtra) MarshalRLPTo(dst []byte) []byte
MarshalRLPTo defines the marshal function wrapper for IstanbulExtra
func (*IstanbulExtra) MarshalRLPWith ¶
func (i *IstanbulExtra) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value
MarshalRLPWith defines the marshal function implementation for IstanbulExtra
func (*IstanbulExtra) UnmarshalRLP ¶
func (i *IstanbulExtra) UnmarshalRLP(input []byte) error
UnmarshalRLP defines the unmarshal function wrapper for IstanbulExtra
func (*IstanbulExtra) UnmarshalRLPFrom ¶
UnmarshalRLPFrom defines the unmarshal implementation for IstanbulExtra
type Nonce ¶
type Nonce [8]byte
func (Nonce) MarshalText ¶
MarshalText implements encoding.TextMarshaler
type PoolTxByNonce ¶
type PoolTxByNonce []*Transaction
PoolTxByNonce 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 (PoolTxByNonce) Len ¶
func (s PoolTxByNonce) Len() int
func (PoolTxByNonce) Less ¶
func (s PoolTxByNonce) Less(i, j int) bool
func (PoolTxByNonce) Swap ¶
func (s PoolTxByNonce) Swap(i, j int)
type RLPMarshaler ¶
type RLPStoreMarshaler ¶
type RLPStoreUnmarshaler ¶
type RLPUnmarshaler ¶
type Receipt ¶
type Receipt struct {
// consensus fields
Root Hash
CumulativeGasUsed uint64
LogsBloom Bloom
Logs []*Log
Status *ReceiptStatus
// context fields
GasUsed uint64
ContractAddress *Address
TxHash Hash
}
func (*Receipt) MarshalLogsWith ¶
MarshalLogsWith marshals the logs of the receipt to RLP with a specific fastrlp.Arena
func (*Receipt) MarshalRLP ¶
func (*Receipt) MarshalRLPTo ¶
func (*Receipt) MarshalRLPWith ¶
MarshalRLPWith marshals a receipt with a specific fastrlp.Arena
func (*Receipt) MarshalStoreRLPTo ¶
func (*Receipt) MarshalStoreRLPWith ¶
func (*Receipt) SetContractAddress ¶
func (*Receipt) SetStatus ¶
func (r *Receipt) SetStatus(s ReceiptStatus)
func (*Receipt) UnmarshalRLP ¶
func (*Receipt) UnmarshalRLPFrom ¶
UnmarshalRLP unmarshals a Receipt in RLP format
func (*Receipt) UnmarshalStoreRLP ¶
type ReceiptStatus ¶
type ReceiptStatus uint64
const ( ReceiptFailed ReceiptStatus = iota ReceiptSuccess )
type Receipts ¶
type Receipts []*Receipt
func (Receipts) MarshalRLPTo ¶
func (*Receipts) MarshalRLPWith ¶
func (Receipts) MarshalStoreRLPTo ¶
func (*Receipts) MarshalStoreRLPWith ¶
func (*Receipts) UnmarshalRLP ¶
func (*Receipts) UnmarshalRLPFrom ¶
func (*Receipts) UnmarshalStoreRLP ¶
type Snapshot ¶
type Snapshot struct {
// block number when the snapshot was created
Number uint64
// block hash when the snapshot was created
Hash string
// votes casted in chronological order
Votes []*Vote
// current set of validators
Set Validators
}
Snapshot is the current state at a given point in time for validators and votes
type Transaction ¶
type Transaction struct {
Nonce uint64
GasPrice *big.Int
Gas uint64
To *Address
Value *big.Int
Input []byte
V *big.Int
R *big.Int
S *big.Int
From Address
// time at which the node received the tx
ReceivedTime time.Time
// contains filtered or unexported fields
}
func (*Transaction) Cost ¶
func (t *Transaction) Cost() *big.Int
Cost returns gas * gasPrice + value
func (*Transaction) ExceedsBlockGasLimit ¶
func (t *Transaction) ExceedsBlockGasLimit(blockGasLimit uint64) bool
func (*Transaction) Hash ¶
func (t *Transaction) Hash() Hash
func (*Transaction) IsContractCreation ¶
func (t *Transaction) IsContractCreation() bool
func (*Transaction) IsUnderpriced ¶
func (t *Transaction) IsUnderpriced(priceLimit uint64) bool
func (*Transaction) MarshalRLP ¶
func (t *Transaction) MarshalRLP() []byte
func (*Transaction) MarshalRLPTo ¶
func (t *Transaction) MarshalRLPTo(dst []byte) []byte
func (*Transaction) MarshalRLPWith ¶
func (t *Transaction) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value
MarshalRLPWith marshals the transaction to RLP with a specific fastrlp.Arena
func (*Transaction) MarshalStoreRLPTo ¶
func (t *Transaction) MarshalStoreRLPTo(dst []byte) []byte
func (*Transaction) MarshalStoreRLPWith ¶
func (t *Transaction) MarshalStoreRLPWith(a *fastrlp.Arena) *fastrlp.Value
func (*Transaction) Size ¶
func (t *Transaction) Size() uint64
func (*Transaction) UnmarshalRLP ¶
func (t *Transaction) UnmarshalRLP(input []byte) error
func (*Transaction) UnmarshalRLPFrom ¶
UnmarshalRLP unmarshals a Transaction in RLP format
func (*Transaction) UnmarshalStoreRLP ¶
func (t *Transaction) UnmarshalStoreRLP(input []byte) error
func (*Transaction) UnmarshalStoreRLPFrom ¶
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(txs map[Address][]*Transaction) *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() *Transaction
Peek returns the next transaction by price.
func (*TransactionsByPriceAndNonce) Pop ¶
func (t *TransactionsByPriceAndNonce) Pop()
Pop removes the best transaction, *not* replacing it with the next one from the same account. This should be used when a transaction cannot be executed and hence all subsequent ones should be discarded from the same account.
func (*TransactionsByPriceAndNonce) Shift ¶
func (t *TransactionsByPriceAndNonce) Shift()
Shift replaces the current best head with the next one from the same account.
type TxByPriceAndTime ¶
type TxByPriceAndTime []*Transaction
TxByPriceAndTime 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 (TxByPriceAndTime) Len ¶
func (s TxByPriceAndTime) Len() int
func (TxByPriceAndTime) Less ¶
func (s TxByPriceAndTime) Less(i, j int) bool
func (*TxByPriceAndTime) Pop ¶
func (s *TxByPriceAndTime) Pop() interface{}
func (*TxByPriceAndTime) Push ¶
func (s *TxByPriceAndTime) Push(x interface{})
func (TxByPriceAndTime) Swap ¶
func (s TxByPriceAndTime) Swap(i, j int)
type Validators ¶
type Validators []Address
func (*Validators) Add ¶
func (v *Validators) Add(addr Address)
Add adds a new address to the validator set
func (*Validators) CalcProposer ¶
func (v *Validators) CalcProposer(round uint64, lastProposer Address) Address
CalcProposer calculates the address of the next proposer, from the validator set
func (*Validators) Del ¶
func (v *Validators) Del(addr Address)
Del removes an address from the validator set
func (*Validators) Equal ¶
func (v *Validators) Equal(vv *Validators) bool
Equal checks if 2 validator sets are equal
func (*Validators) Includes ¶
func (v *Validators) Includes(addr Address) bool
Includes checks if the address is in the validator set
func (*Validators) Index ¶
func (v *Validators) Index(addr Address) int
Index returns the index of the passed in address in the validator set. Returns -1 if not found