types

package
v0.0.0-...-ce7d804 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2020 License: LGPL-3.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	EventNewBlock       = "NewBlock"
	EventNewBlockHeader = "NewBlockHeader"
	EventLog            = "Log"
)

Reserved event types

View Source
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)
)
View Source
const (
	// EventTypeKey is a reserved key, used to specify event type in tags.
	EventTypeKey = "th.event"
)

Variables

View Source
var (
	EventQueryNewBlock       = QueryForEvent(EventNewBlock)
	EventQueryNewBlockHeader = QueryForEvent(EventNewBlockHeader)
	EventQueryLog            = QueryForEvent(EventLog)
)
View Source
var ErrGasLimitReached = errors.New("gas limit reached")
View Source
var (
	// ErrInvalidSignParam is returned if the transaction signed with error param.
	ErrInvalidSignParam = errors.New("invalid sign param for signer")
)

Functions

func BalHash

func BalHash(x interface{}) (h common.Hash)

func CreateBloom

func CreateBloom(mreceipts Receipts) bloombits.Bloom

func LogsBloom

func LogsBloom(logs []*Log) *big.Int

func QueryForEvent

func QueryForEvent(eventType string) tmpubsub.Query

Types

type EventBus

type EventBus struct {
	cmn.BaseService
	// contains filtered or unexported fields
}

EventBus is a common bus for all events going through the system. All calls are proxied to underlying pubsub server. All events must be published using EventBus to ensure correct data types.

func NewEventBus

func NewEventBus() *EventBus

NewEventBus returns a new event bus.

func NewEventBusWithBufferCapacity

func NewEventBusWithBufferCapacity(cap int) *EventBus

NewEventBusWithBufferCapacity returns a new event bus with the given buffer capacity.

func NewEventBusWithLogger

func NewEventBusWithLogger(l log.Logger) *EventBus

func (*EventBus) OnStart

func (b *EventBus) OnStart() error

func (*EventBus) OnStop

func (b *EventBus) OnStop()

func (*EventBus) Publish

func (b *EventBus) Publish(eventType string, eventData THEventData) error

func (*EventBus) PublishEventLog

func (b *EventBus) PublishEventLog(event EventDataLog) error

func (*EventBus) PublishEventNewBlock

func (b *EventBus) PublishEventNewBlock(event EventDataNewBlock) error

func (*EventBus) PublishEventNewBlockHeader

func (b *EventBus) PublishEventNewBlockHeader(event EventDataNewBlockHeader) error

func (*EventBus) SetLogger

func (b *EventBus) SetLogger(l log.Logger)

func (*EventBus) Subscribe

func (b *EventBus) Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, out chan<- interface{}) error

func (*EventBus) Unsubscribe

func (b *EventBus) Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error

func (*EventBus) UnsubscribeAll

func (b *EventBus) UnsubscribeAll(ctx context.Context, subscriber string) error

type EventDataLog

type EventDataLog struct {
	Logs []*Log `json:"logs"`
}

type EventDataNewBlock

type EventDataNewBlock struct {
	Block interface{} `json:"block"`
}

type EventDataNewBlockHeader

type EventDataNewBlockHeader struct {
	Header interface{} `json:"header"`
}

type GasPool

type GasPool uint64

GasPool tracks the amount of gas available during execution of the transactions in a block. The zero value is a pool with zero gas available.

func (*GasPool) AddGas

func (gp *GasPool) AddGas(amount uint64) *GasPool

AddGas makes gas available for execution.

func (*GasPool) Gas

func (gp *GasPool) Gas() uint64

Gas returns the amount of gas remaining in the pool.

func (*GasPool) String

func (gp *GasPool) String() string

func (*GasPool) SubGas

func (gp *GasPool) SubGas(amount uint64) error

SubGas deducts the given amount from the pool if enough gas is available and returns an error otherwise.

type HashList

type HashList []common.Hash

func (HashList) Hash

func (hl HashList) Hash() common.Hash

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" bal:"-"`
	BlockTime uint64 `json:"blockTime" gencodec:"required"`
}

Log represents a contract log event. These events are generated by the LOG opcode and stored/indexed by the node.

func (Log) MarshalJSON

func (l Log) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Log) String

func (l *Log) String() string

func (*Log) UnmarshalJSON

func (l *Log) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type Receipt

type Receipt struct {
	// Consensus fields
	PostState         []byte          `json:"root"`
	Status            uint64          `json:"status"`
	VMErr             string          `json:"vmErr"`
	CumulativeGasUsed uint64          `json:"cumulativeGasUsed" gencodec:"required"`
	Bloom             bloombits.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"`
	ZoneID          int            `json:"zoneid"`
}

Receipt represents the results of a transaction.

func NewReceipt

func NewReceipt(root []byte, vmerr error, cumulativeGasUsed uint64) *Receipt

NewReceipt creates a barebone transaction receipt, copying the init fields.

func (*Receipt) Hash

func (r *Receipt) Hash() common.Hash

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.

type ReceiptList

type ReceiptList []*Receipt

Receipts is a wrapper around a Receipt array to implement DerivableList.

func (ReceiptList) Hash

func (r ReceiptList) Hash() common.Hash

type Receipts

type Receipts map[int]ReceiptList

func (Receipts) GetReceipt

func (r Receipts) GetReceipt(zoneid int, index uint64) *Receipt

func (Receipts) Hash

func (r Receipts) Hash() common.Hash

type STDEIP155Signer

type STDEIP155Signer struct {
	// contains filtered or unexported fields
}

STDEIP155Signer implements STDSigner using the EIP155 rules.

func NewSTDEIP155Signer

func NewSTDEIP155Signer(signParam *big.Int) STDEIP155Signer

NewSTDEIP155Signer return a STDEIP155Signer

func (STDEIP155Signer) Equal

func (s STDEIP155Signer) Equal(s2 STDSigner) bool

Equal returns true if the given signer is the same as the receiver.

func (STDEIP155Signer) Hash

func (s STDEIP155Signer) Hash(data SignerData) common.Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the signdata.

func (STDEIP155Signer) Sender

func (s STDEIP155Signer) Sender(data SignerData) (common.Address, error)

Sender returns the sender address of the signdata.

func (STDEIP155Signer) SignParam

func (s STDEIP155Signer) SignParam() *big.Int

SignParam return the field signParam

func (STDEIP155Signer) SignatureValues

func (s STDEIP155Signer) SignatureValues(sig []byte) (R, S, V *big.Int, err error)

SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type STDFrontierSigner

type STDFrontierSigner struct{}

STDFrontierSigner implements TransactionInterface using the homestead rules.

func (STDFrontierSigner) Equal

func (s STDFrontierSigner) Equal(s2 STDSigner) bool

Equal returns true if the given signer is the same as the receiver.

func (STDFrontierSigner) Hash

func (s STDFrontierSigner) Hash(data SignerData) common.Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (STDFrontierSigner) Sender

func (s STDFrontierSigner) Sender(data SignerData) (common.Address, error)

Sender returns the sender address of the signdata.

func (STDFrontierSigner) SignParam

func (s STDFrontierSigner) SignParam() *big.Int

SignParam return the field signParam

func (STDFrontierSigner) SignatureValues

func (s STDFrontierSigner) SignatureValues(sig []byte) (R, S, V *big.Int, err error)

SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type STDHomesteadSigner

type STDHomesteadSigner struct{ STDFrontierSigner }

STDHomesteadSigner implements TransactionInterface using the homestead rules.

func (STDHomesteadSigner) Equal

func (s STDHomesteadSigner) Equal(s2 STDSigner) bool

Equal returns true if the given signer is the same as the receiver.

func (STDHomesteadSigner) Sender

func (s STDHomesteadSigner) Sender(data SignerData) (common.Address, error)

Sender returns the sender address of the signdata.

func (STDHomesteadSigner) SignParam

func (s STDHomesteadSigner) SignParam() *big.Int

SignParam return the field signParam

func (STDHomesteadSigner) SignatureValues

func (s STDHomesteadSigner) SignatureValues(sig []byte) (*big.Int, *big.Int, *big.Int, error)

SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type STDSigner

type STDSigner interface {
	// Sender returns the sender address of the signdata.
	Sender(data SignerData) (common.Address, error)
	// SignatureValues returns the raw R, S, V values corresponding to the
	// given signature.
	SignatureValues(sig []byte) (r, s, v *big.Int, err error)
	// Hash returns the hash to be signed.
	Hash(data SignerData) common.Hash
	// Equal returns true if the given signer is the same as the receiver.
	Equal(STDSigner) bool
	// SignParam return the field signParam
	SignParam() *big.Int
}

STDSigner encapsulates signdata signature handling. Note that this interface is not a stable API and may change at any time to accommodate new protocol rules.

type SignerData

type SignerData interface {
	Recover(hash common.Hash, signParamMul *big.Int, homestead bool) (common.Address, error)
	SignParam() *big.Int
	Protected() bool
	SignFields() []interface{}
	From() *atomic.Value
}

type THEventData

type THEventData interface {
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL