Documentation
¶
Index ¶
- Constants
- Variables
- func AddressRecoverFromHeader(h *types.Header) (types.Address, error)
- func AssignExtraValidators(h *types.Header, validators []types.Address) error
- func DecodeExtraDataFields(data []byte) (map[string][]byte, error)
- func EncodeExtraDataFields(data map[string][]byte) []byte
- func GetExtraDataBeginDisputeResolutionTarget(h *types.Header) (types.Hash, bool)
- func GetExtraDataEndDisputeResolutionTarget(h *types.Header) (types.Hash, bool)
- func GetExtraDataFraudProofTarget(h *types.Header) (types.Hash, bool)
- func PutValidatorExtra(h *types.Header, istanbulExtra *ValidatorExtra) error
- func WriteSeal(prv *ecdsa.PrivateKey, h *types.Header) (*types.Header, error)
- type BlockBuilderFactory
- type Builder
- type ValidatorExtra
Constants ¶
const ( // KeyExtraValidators is key that identifies the `ValidatorsExtra` object // serialized in `ExtraData`. KeyExtraValidators = "EXTRA_VALIDATORS" // KeyFraudProofOf is key that identifies the fraudproof objected malicious // block hash in `ExtraData` of the fraudproof block header. KeyFraudProofOf = "FRAUD_PROOF_OF" // KeyBeginDisputeResolutionOf used to understand which tx from the txpool we need to pick // when writing fraud slash block KeyBeginDisputeResolutionOf = "BEGIN_DISPUTE_RESOLUTION_OF" // KeyEndDisputeResolutionOf used to understand which block hash was used to slash the node // in order to end dispute resolution on all of the nodes KeyEndDisputeResolutionOf = "END_DISPUTE_RESOLUTION_OF" )
const ( SourceAvail = "Avail" SourceWatchTower = "WatchTower" )
Constants defining different block sources
Variables ¶
var ErrInvalidHash = errors.New("invalid hash")
ErrInvalidHash represents an error indicating an invalid hash.
var ErrSignKeyMissing = errors.New("signing key missing")
ErrSignKeyMissing represents an error indicating a missing signing key.
Functions ¶
func AddressRecoverFromHeader ¶
AddressRecoverFromHeader recovers the address from the header seal. It takes the header and returns the recovered address and an error if there is an issue.
func AssignExtraValidators ¶
AssignExtraValidators adds the validators to the extra data field in the header. It takes the header and a slice of validator addresses and modifies the header's extra data field accordingly. Returns an error if there is an issue decoding or encoding the extra data field.
func DecodeExtraDataFields ¶
DecodeExtraDataFields decodes the byte slice into a map of extra data fields. It takes a byte slice representing the encoded data and returns a map of string keys to byte slice values.
func EncodeExtraDataFields ¶
EncodeExtraDataFields encodes the given map of extra data fields into a byte slice. It takes a map of string keys to byte slice values and returns a byte slice representation of the encoded data.
func GetExtraDataBeginDisputeResolutionTarget ¶
GetExtraDataBeginDisputeResolutionTarget returns the begin dispute resolution target from the extra data field in the header. It takes the header and returns the begin dispute resolution target as a Hash value. Returns the begin dispute resolution target and a boolean indicating if it was found in the extra data field.
func GetExtraDataEndDisputeResolutionTarget ¶
GetExtraDataEndDisputeResolutionTarget returns the end dispute resolution target from the extra data field in the header. It takes the header and returns the end dispute resolution target as a Hash value. Returns the end dispute resolution target and a boolean indicating if it was found in the extra data field.
func GetExtraDataFraudProofTarget ¶
GetExtraDataFraudProofTarget returns the fraudproof target from the extra data field in the header. It takes the header and returns the fraudproof target as a Hash value. Returns the fraudproof target and a boolean indicating if it was found in the extra data field.
func PutValidatorExtra ¶
func PutValidatorExtra(h *types.Header, istanbulExtra *ValidatorExtra) error
PutValidatorExtra sets the extra data field in the header to the given ValidatorExtra. It takes the header and a ValidatorExtra struct and modifies the header's extra data field accordingly. Returns an error if there is an issue decoding or encoding the extra data field.
Types ¶
type BlockBuilderFactory ¶
type BlockBuilderFactory interface {
// FromParentHash creates a block builder using the parent block's hash.
FromParentHash(parent types.Hash) (Builder, error)
// FromBlockchainHead creates a block builder using the blockchain's head.
FromBlockchainHead() (Builder, error)
}
BlockBuilderFactory is a factory interface for creating block builders.
func NewBlockBuilderFactory ¶
func NewBlockBuilderFactory(blockchain blockchain, executor *state.Executor, logger hclog.Logger) BlockBuilderFactory
NewBlockBuilderFactory creates a new block builder factory.
type Builder ¶
type Builder interface {
// SetBlockNumber sets the block number and returns the builder.
SetBlockNumber(number uint64) Builder
// SetCoinbaseAddress sets the coinbase address and returns the builder.
SetCoinbaseAddress(coinbaseAddr types.Address) Builder
// SetDifficulty sets the block difficulty and returns the builder.
SetDifficulty(d uint64) Builder
// SetExtraDataField sets an extra data field with a key-value pair and returns the builder.
SetExtraDataField(key string, value []byte) Builder
// SetGasLimit sets the gas limit and returns the builder.
SetGasLimit(limit uint64) Builder
// SetParentStateRoot sets the parent state root and returns the builder.
SetParentStateRoot(parentRoot types.Hash) Builder
// AddTransactions adds transactions to the block and returns the builder.
AddTransactions(txs ...*types.Transaction) Builder
// SignWith signs the block with the provided private key and returns the builder.
SignWith(signKey *ecdsa.PrivateKey) Builder
// Build constructs and returns the built block.
Build() (*types.Block, error)
// Write writes the built block to the specified source.
Write(src string) error
}
Builder provides a builder interface for constructing blocks.
type ValidatorExtra ¶
ValidatorExtra defines the structure of the extra data field for validators.
func (*ValidatorExtra) MarshalRLPTo ¶
func (i *ValidatorExtra) MarshalRLPTo(dst []byte) []byte
MarshalRLPTo marshals the ValidatorExtra struct to an RLP-encoded byte slice. It takes the ValidatorExtra struct and a destination byte slice, and returns the marshaled byte slice.
func (*ValidatorExtra) MarshalRLPWith ¶
func (i *ValidatorExtra) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value
MarshalRLPWith marshals the ValidatorExtra struct to an RLP value using the given RLP arena. It takes the ValidatorExtra struct and an RLP arena, and returns the RLP value.
func (*ValidatorExtra) UnmarshalRLP ¶
func (i *ValidatorExtra) UnmarshalRLP(input []byte) error
UnmarshalRLP unmarshals the ValidatorExtra struct from an RLP-encoded byte slice. It takes the input byte slice and returns an error if there is an issue unmarshaling the data.
func (*ValidatorExtra) UnmarshalRLPFrom ¶
UnmarshalRLPFrom unmarshals the ValidatorExtra struct from an RLP value using the given RLP parser and value. It takes the RLP parser, RLP value, and returns an error if there is an issue unmarshaling the data.