repository

package
v0.0.0-...-70addda Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EthereumBlock

type EthereumBlock struct {
	Id         int    `gorm:"column:id;primaryKey;autoIncrement"`
	BlockNum   uint64 `gorm:"column:block_num;uniqueIndex;"`
	BlockHash  string `gorm:"column:block_hash;uniqueIndex;"`
	BlockTime  uint64 `gorm:"column:block_time;"`
	ParentHash string `gorm:"column:parent_hash;"`
}
CREATE TABLE blocks (
   id INT AUTO_INCREMENT PRIMARY KEY,
   block_num BIGINT UNSIGNED NOT NULL,
   block_hash VARCHAR(66) NOT NULL,  -- 66 chars to accommodate 0x prefix and 64 hex characters
   block_time BIGINT UNSIGNED NOT NULL,
   parent_hash VARCHAR(66) NOT NULL,
   UNIQUE (block_num),
   UNIQUE (block_hash)

);

func (*EthereumBlock) TableName

func (e *EthereumBlock) TableName() string

type EthereumIndexRepository

type EthereumIndexRepository interface {
	AddBlocks(records []*EthereumBlock) error
	AddTransactions(records []*EthereumTransaction) error
	AddLogs(records []*EthereumLog) error
	GetLatestBlock(limit int) ([]*EthereumBlock, error)
	GetBlock(blockNum uint64) (*EthereumBlock, error)
	GetTransaction(txHash string) (*EthereumTransaction, error)
	GetTransactions(blockNum uint64) ([]*EthereumTransaction, error)
	GetLogs(txHash string) ([]*EthereumLog, error)
}

func NewEthereumIndexGormImpl

func NewEthereumIndexGormImpl(dsn string) EthereumIndexRepository

type EthereumLog

type EthereumLog struct {
	Id       int    `gorm:"column:id;primaryKey;autoIncrement"`
	TxHash   string `gorm:"column:tx_hash"`
	LogIndex uint64 `gorm:"column:log_index"`
	Data     []byte `gorm:"column:data"`
}

func (*EthereumLog) TableName

func (e *EthereumLog) TableName() string

type EthereumTransaction

type EthereumTransaction struct {
	Id          int    `gorm:"column:id;primaryKey;autoIncrement"`
	TxHash      string `gorm:"column:tx_hash;uniqueIndex"`
	BlockNum    uint64 `gorm:"column:block_num"`
	FromAddress string `gorm:"column:from_address"`
	ToAddress   string `gorm:"column:to_address"`
	Nonce       uint64 `gorm:"column:nonce"`
	Data        []byte `gorm:"column:data"`
	Value       uint64 `gorm:"column:value"`
}
CREATE TABLE transactions (
   id INT AUTO_INCREMENT PRIMARY KEY,
   tx_hash VARCHAR(66) NOT NULL,  -- 66 chars for 0x prefix and 64 hex characters
   block_num BIGINT UNSIGNED NOT NULL,
   from_address VARCHAR(42) NOT NULL,  -- 42 chars for Ethereum addresses (0x + 40 hex)
   to_address VARCHAR(42),
   nonce BIGINT UNSIGNED,
   data BINARY,
   value BIGINT UNSIGNED NOT NULL,
   FOREIGN KEY (block_num) REFERENCES blocks(block_num),
   UNIQUE (tx_hash)

);

func (*EthereumTransaction) TableName

func (e *EthereumTransaction) TableName() string

type Tabler

type Tabler interface {
	TableName() string
}

Jump to

Keyboard shortcuts

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