Documentation ¶
Overview ¶
Copyright 2023 The N42 Authors This file is part of the N42 library.
The N42 library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The N42 library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the N42 library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- func Bloom9(data []byte) []byte
- func BloomLookup(bin Bloom, topic bytesBacked) bool
- func LogsBloom(logs []*Log) []byte
- type Block
- func (b *Block) BaseFee64() *uint256.Int
- func (b *Block) Body() IBody
- func (b *Block) Coinbase() types.Address
- func (b *Block) Difficulty() *uint256.Int
- func (b *Block) FromProtoMessage(message proto.Message) error
- func (b *Block) GasLimit() uint64
- func (b *Block) GasUsed() uint64
- func (b *Block) Hash() types.Hash
- func (b *Block) Header() IHeader
- func (b *Block) Marshal() ([]byte, error)
- func (b *Block) Nonce() uint64
- func (b *Block) Number64() *uint256.Int
- func (b *Block) ParentHash() types.Hash
- func (b *Block) SendersToTxs(senders []types.Address)
- func (b *Block) StateRoot() types.Hash
- func (b *Block) Time() uint64
- func (b *Block) ToProtoMessage() proto.Message
- func (b *Block) Transaction(hash types.Hash) *transaction.Transaction
- func (b *Block) Transactions() []*transaction.Transaction
- func (b *Block) TxHash() types.Hash
- func (b *Block) Uncles() []*Header
- func (b *Block) Unmarshal(data []byte) error
- func (b *Block) WithSeal(header IHeader) *Block
- type BlockNonce
- type Blocks
- type Bloom
- type Body
- func (b *Body) FromProtoMessage(message proto.Message) error
- func (b *Body) Reward() []*Reward
- func (b *Body) SendersFromTxs() []types.Address
- func (b *Body) SendersToTxs(senders []types.Address)
- func (b *Body) ToProtoMessage() proto.Message
- func (b *Body) Transactions() []*transaction.Transaction
- func (b *Body) Verifier() []*Verify
- type BodyForStorage
- type Header
- func (h *Header) BaseFee64() *uint256.Int
- func (h *Header) FromProtoMessage(message proto.Message) error
- func (h Header) Hash() types.Hash
- func (h *Header) Marshal() ([]byte, error)
- func (h *Header) Number64() *uint256.Int
- func (h *Header) StateRoot() types.Hash
- func (h *Header) ToProtoMessage() proto.Message
- func (h *Header) Unmarshal(data []byte) error
- type IBlock
- type IBody
- type IHeader
- type Log
- type Logs
- type RawBody
- type Receipt
- type Receipts
- func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer)
- func (rs *Receipts) FromProtoMessage(receipts *types_pb.Receipts) error
- func (rs Receipts) Len() int
- func (rs *Receipts) Marshal() ([]byte, error)
- func (rs *Receipts) ToProtoMessage() proto.Message
- func (rs *Receipts) Unmarshal(data []byte) error
- type Reward
- type Rewards
- type Verify
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) )
Variables ¶
This section is empty.
Functions ¶
func BloomLookup ¶
BloomLookup is a convenience-method to check presence int he bloom filter
Types ¶
type Block ¶
type Block struct { ReceiveAt time.Time ReceivedFrom interface{} // contains filtered or unexported fields }
func NewBlockFromStorage ¶
func (*Block) Difficulty ¶
func (*Block) ParentHash ¶
func (*Block) SendersToTxs ¶
func (*Block) ToProtoMessage ¶
func (*Block) Transaction ¶
func (b *Block) Transaction(hash types.Hash) *transaction.Transaction
func (*Block) Transactions ¶
func (b *Block) Transactions() []*transaction.Transaction
type BlockNonce ¶
type BlockNonce [8]byte
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 todo copy eth
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) Big ¶
Big converts b to a big integer. Note: Converting a bloom filter to a big.Int and then calling GetBytes does not return the same bytes, since big.Int will trim leading zeroes
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 { Txs []*transaction.Transaction Verifiers []*Verify Rewards []*Reward }
func (*Body) SendersFromTxs ¶
func (*Body) SendersToTxs ¶
func (*Body) ToProtoMessage ¶
func (*Body) Transactions ¶
func (b *Body) Transactions() []*transaction.Transaction
type BodyForStorage ¶
type Header ¶
type Header struct { ParentHash types.Hash `json:"parentHash" gencodec:"required"` Coinbase types.Address `json:"miner"` Root types.Hash `json:"stateRoot" gencodec:"required"` TxHash types.Hash `json:"transactionsRoot" gencodec:"required"` ReceiptHash types.Hash `json:"receiptsRoot" gencodec:"required"` Bloom Bloom `json:"logsBloom" gencodec:"required"` Difficulty *uint256.Int `json:"difficulty" gencodec:"required"` Number *uint256.Int `json:"number" gencodec:"required"` GasLimit uint64 `json:"gasLimit" gencodec:"required"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` Time uint64 `json:"timestamp" gencodec:"required"` MixDigest types.Hash `json:"mixHash"` Nonce BlockNonce `json:"nonce"` Extra []byte `json:"extraData" gencodec:"required"` // BaseFee was added by EIP-1559 and is ignored in legacy headers. BaseFee *uint256.Int `json:"baseFeePerGas" rlp:"optional"` Signature types.Signature `json:"signature"` // contains filtered or unexported fields }
func CopyHeader ¶
func (*Header) ToProtoMessage ¶
type IBlock ¶
type IBlock interface { IHeader Header() IHeader Body() IBody Transaction(hash types.Hash) *transaction.Transaction Transactions() []*transaction.Transaction Number64() *uint256.Int Difficulty() *uint256.Int Time() uint64 GasLimit() uint64 GasUsed() uint64 Nonce() uint64 Coinbase() types.Address ParentHash() types.Hash TxHash() types.Hash WithSeal(header IHeader) *Block }
func NewBlock ¶
func NewBlock(h IHeader, txs []*transaction.Transaction) IBlock
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 NewBlockFromReceipt ¶
func NewBlockFromReceipt(h IHeader, txs []*transaction.Transaction, uncles []IHeader, receipts []*Receipt, reward []*Reward) IBlock
type IBody ¶
type IBody interface { Verifier() []*Verify Reward() []*Reward Transactions() []*transaction.Transaction ToProtoMessage() proto.Message FromProtoMessage(message proto.Message) error }
type Log ¶
type Log struct { // Consensus fields: // address of the contract that generated the event Address types.Address `json:"address" gencodec:"required"` // list of topics provided by the contract. Topics []types.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 *uint256.Int `json:"blockNumber"` // hash of the transaction TxHash types.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 types.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"` }
func (*Log) ToProtoMessage ¶
type Receipt ¶
type Receipt struct { // Consensus fields: These fields are defined by the Yellow Paper Type uint8 `json:"type,omitempty"` 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: These fields are added by geth when processing a transaction. // They are stored in the chain database. TxHash types.Hash `json:"transactionHash" gencodec:"required"` ContractAddress types.Address `json:"contractAddress"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` // Inclusion information: These fields provide information about the inclusion of the // transaction corresponding to this receipt. BlockHash types.Hash `json:"blockHash,omitempty"` BlockNumber *uint256.Int `json:"blockNumber,omitempty"` TransactionIndex uint `json:"transactionIndex"` }
type Receipts ¶
type Receipts []*Receipt
func (Receipts) EncodeIndex ¶
EncodeIndex encodes the i'th receipt to w.