types

package
v0.0.0-...-1329066 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LastBlockNumID is the identifier to access the last block number in the database
	LastBlockNumID = 0xBEEF

	// LastTxHashID is the identifier to access the last transaction hash in the database
	LastTxHashID = 0xBEF0
)

Variables

This section is empty.

Functions

func BytesToEthHex

func BytesToEthHex(b []byte) string

EthHexToBytes converts an Ethereum hex string to bytes

func FromReceiptDBType

func FromReceiptDBType(receipt ReceiptDB) (*ethtypes.Receipt, error)

FromReceiptDBType : Converts a ReceiptDB type to an Ethereum receipt

func FromTransactionDBType

func FromTransactionDBType(transaction TransactionDB) (*ethtypes.Transaction, error)

FromTransactionDBType : Converts a TransactionDB type to an Ethereum transaction

func FromTransactionResultDB

func FromTransactionResultDB(txResult TransactionResultDB) (btcjson.GetTransactionResult, error)

Types

type DynamicTicker

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

DynamicTicker is a ticker that can have its interval updated

func NewDynamicTicker

func NewDynamicTicker(name string, interval uint64) (*DynamicTicker, error)

NewDynamicTicker creates a new DynamicTicker

func (*DynamicTicker) C

func (t *DynamicTicker) C() <-chan time.Time

C returns the channel of the ticker

func (*DynamicTicker) Stop

func (t *DynamicTicker) Stop()

Stop stops the ticker

func (*DynamicTicker) UpdateInterval

func (t *DynamicTicker) UpdateInterval(newInterval uint64, logger zerolog.Logger)

UpdateInterval updates the interval of the ticker

type InboundCategory

type InboundCategory int

InboundCategory is an enum representing the category of an inbound event

const (
	// InboundCategoryUnknown represents an unknown inbound
	InboundCategoryUnknown InboundCategory = iota

	// InboundCategoryGood represents a processable inbound
	InboundCategoryGood

	// InboundCategoryDonation represents a donation inbound
	InboundCategoryDonation

	// InboundCategoryRestricted represents a restricted inbound
	InboundCategoryRestricted
)

type InboundEvent

type InboundEvent struct {
	// SenderChainID is the chain ID of the sender
	SenderChainID int64

	// Sender is the sender address
	Sender string

	// Receiver is the receiver address
	Receiver string

	// TxOrigin is the origin of the transaction
	TxOrigin string

	// Value is the amount of token
	Amount uint64

	// Memo is the memo attached to the inbound
	Memo []byte

	// BlockNumber is the block number of the inbound
	BlockNumber uint64

	// TxHash is the hash of the inbound
	TxHash string

	// Index is the index of the event
	Index uint32

	// CoinType is the coin type of the inbound
	CoinType coin.CoinType

	// Asset is the asset of the inbound
	Asset string
}

InboundEvent represents an inbound event TODO: we should consider using this generic struct when it applies (e.g. for Bitcoin, Solana, etc.) https://github.com/zeta-chain/node/issues/2495

func (*InboundEvent) Category

func (event *InboundEvent) Category() InboundCategory

Category returns the category of the inbound event

func (*InboundEvent) DecodeMemo

func (event *InboundEvent) DecodeMemo() error

DecodeMemo decodes the receiver from the memo bytes

type LastBlockSQLType

type LastBlockSQLType struct {
	gorm.Model
	Num uint64
}

LastBlockSQLType is a model for storing the last block number

func ToLastBlockSQLType

func ToLastBlockSQLType(lastBlock uint64) *LastBlockSQLType

ToLastBlockSQLType converts a last block number to a LastBlockSQLType

type LastTransactionSQLType

type LastTransactionSQLType struct {
	gorm.Model
	Hash string
}

LastTransactionSQLType is a model for storing the last transaction hash

func ToLastTxHashSQLType

func ToLastTxHashSQLType(lastTx string) *LastTransactionSQLType

ToLastTxHashSQLType converts a last transaction hash to a LastTransactionSQLType

type OutboundHashSQLType

type OutboundHashSQLType struct {
	gorm.Model
	Key  string
	Hash string
}

func ToOutboundHashSQLType

func ToOutboundHashSQLType(hash string, key string) OutboundHashSQLType

type ReceiptDB

type ReceiptDB struct {
	// Consensus fields: These fields are defined by the Yellow Paper
	Type              uint8
	PostState         []byte
	Status            uint64
	CumulativeGasUsed uint64
	Bloom             []byte
	Logs              []byte

	// Implementation fields: These fields are added by geth when processing a transaction.
	// They are stored in the chain database.
	TxHash          common.Hash
	ContractAddress common.Address
	GasUsed         uint64

	// Inclusion information: These fields provide information about the inclusion of the
	// transaction corresponding to this receipt.
	BlockHash        common.Hash
	BlockNumber      *big.Int `gorm:"embedded"`
	TransactionIndex uint
}

ReceiptDB : A modified receipt struct that the relational mapping can translate

func ToReceiptDBType

func ToReceiptDBType(receipt *ethtypes.Receipt) (ReceiptDB, error)

ToReceiptDBType : Converts an Ethereum receipt to a ReceiptDB type

type ReceiptSQLType

type ReceiptSQLType struct {
	gorm.Model
	Identifier string
	Receipt    ReceiptDB `gorm:"embedded"`
}

func ToReceiptSQLType

func ToReceiptSQLType(receipt *ethtypes.Receipt, index string) (*ReceiptSQLType, error)

ToReceiptSQLType : Converts an Ethereum receipt to a ReceiptSQLType

type Status

type Status struct {
	BTCNumberOfUTXOs int `json:"btc_number_of_utxos"`
}

Status type for telemetry. More fields can be added as needed

type TransactionDB

type TransactionDB struct {
	// Data that can be used for queries
	Type    byte
	ChainID *big.Int `gorm:"embedded"`
	Nonce   uint64
	To      *common.Address
	Hash    common.Hash

	// Serialized go-ethereum transaction
	TransactionData []byte
}

TransactionDB : A modified Transaction struct that the relational mapping can translate. Inner transaction data is defined as an interface from eth types, so it will be serialized and stored as bytes.

func ToTransactionDBType

func ToTransactionDBType(transaction *ethtypes.Transaction) (TransactionDB, error)

ToTransactionDBType : Converts an Ethereum transaction to a TransactionDB type

type TransactionResultDB

type TransactionResultDB struct {
	Amount          float64
	Fee             float64
	Confirmations   int64
	BlockHash       string
	BlockIndex      int64
	BlockTime       int64
	TxID            string
	WalletConflicts []byte
	Time            int64
	TimeReceived    int64
	Details         []byte // btcjson.GetTransactionDetailsResult
	Hex             string
}

func ToTransactionResultDB

func ToTransactionResultDB(txResult btcjson.GetTransactionResult) (TransactionResultDB, error)

type TransactionResultSQLType

type TransactionResultSQLType struct {
	gorm.Model
	Key string
	Tx  TransactionResultDB `gorm:"embedded"`
}

func ToTransactionResultSQLType

func ToTransactionResultSQLType(txResult btcjson.GetTransactionResult, key string) (TransactionResultSQLType, error)

type TransactionSQLType

type TransactionSQLType struct {
	gorm.Model
	Identifier  string
	Transaction TransactionDB `gorm:"embedded"`
}

func ToTransactionSQLType

func ToTransactionSQLType(transaction *ethtypes.Transaction, index string) (*TransactionSQLType, error)

ToTransactionSQLType : Converts an Ethereum transaction to a TransactionSQLType

Jump to

Keyboard shortcuts

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