Documentation
¶
Overview ¶
* Define types and structures relate block
* Define types and structures relate header
Index ¶
Constants ¶
View Source
const ( HashLength = 32 AddressLength = 20 )
Lengths of hashes and addresses in bytes.
View Source
const (
// BloomByteLength represents the number of bytes used in a header log bloom.
BloomByteLength = 256
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address of an Ethereum account.
type Block ¶
type Block struct {
Header *Header
Transactions []*Transaction
HeaderHash Hash `json:"headerHash" gencodec:"required"`
}
type EventCenter ¶
type EventCenter interface {
// subscribe specified eventType with eventFunc
Subscribe(eventType EventType, eventFunc EventFunc) Subscriber
// unsubscribe specified eventType and subscriber
UnSubscribe(eventType EventType, subscriber Subscriber) (err error)
// notify subscriber of eventType
Notify(eventType EventType, value interface{}) (err error)
// notify specified eventFunc
NotifySubscriber(eventFunc EventFunc, value interface{})
// notify subscriber traversing all events
NotifyAll() (errs []error)
// unsubscribe all event
UnSubscribeAll()
}
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
type Header ¶
type Header struct {
ChainID uint64 `json:"chainId" gencodec:"required"` // chainid
PrevBlockHash Hash `json:"prevHash" gencodec:"required"` // preblock hash
StateRoot Hash `json:"stateRoot" gencodec:"required"` // statedb root
TxRoot Hash `json:"txRoot" gencodec:"required"` // transactions root
ReceiptsRoot Hash `json:"receipsRoot" gencodec:"required"` // receipt root
Height uint64 `json:"height" gencodec:"required"` // block height
Timestamp uint64 `json:"timestamp" gencodec:"required"` // timestamp
CoinBase Address `json:"coinbase" gencodec:"required"` // coin base
// not contain when compute header hash
MixDigest Hash `json:"mixDigest" gencodec:"required"` // digest
SigData [][]byte `json:"signData" gencodec:"required"` // SigData
}
Header represents a block header in the Ethereum blockchain.
type Log ¶
type Log struct {
// Consensus fields:
// address of the contract that generated the event
Address Address `json:"address" gencodec:"required"`
// list of topics provided by the contract.
Topics []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 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 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"`
}
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 Hash `json:"transactionHash" gencodec:"required"`
ContractAddress Address `json:"contractAddress"`
GasUsed uint64 `json:"gasUsed" gencodec:"required"`
}
Receipt represents the results of a transaction.
type StorageSize ¶
type StorageSize float64
StorageSize is a wrapper around a float value that supports user friendly formatting.
type Subscriber ¶
type Subscriber chan interface{}
type Transaction ¶
type TxData ¶
type TxData struct {
AccountNonce uint64 `json:"nonce" gencodec:"required"`
Price *big.Int `json:"gasPrice" gencodec:"required"`
GasLimit uint64 `json:"gas" gencodec:"required"`
Recipient *Address `json:"to" rlp:"nil"`
From *Address `json:"from" rlp:"nil"`
Amount *big.Int `json:"value" gencodec:"required"`
Payload []byte `json:"input" gencodec:"required"`
// Signature values
V *big.Int `json:"v" gencodec:"required"`
R *big.Int `json:"r" gencodec:"required"`
S *big.Int `json:"s" gencodec:"required"`
// This is only used when marshaling to JSON.
Hash *Hash `json:"hash" rlp:"-"`
}
Click to show internal directories.
Click to hide internal directories.