model

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2018 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ETHAddress represents ether type in address type
	ETHAddress = common.BytesToAddress([]byte("ETH"))
	// ETHBytes represents ether type in bytes array type
	ETHBytes = ETHAddress.Bytes()
	// RewardToMiner represents a constant at from field in transfer event
	RewardToMiner = common.BytesToAddress([]byte("MINER REWARD"))
	// RewardToUncle represents a constant at from field in transfer event
	RewardToUncle = common.BytesToAddress([]byte("UNCLE REWARD"))

	// Maximum number of uncles allowed in a single block
	MaxUncles = 2
	// ErrTooManyUncles is returned if uncles is larger than 2
	ErrTooManyUncles = errors.New("too many uncles")
	// ErrTooManyMiners is returned if miner is larger than 1
	ErrTooManyMiners  = errors.New("too many miners")
	ErrConfusedUncles = errors.New("confused numbers of uncle")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	ContractAddress []byte `gorm:"-"`
	BlockNumber     int64  `gorm:"size:8;index;unique_index:idx_block_number_address"`
	Address         []byte `gorm:"size:20;index;unique_index:idx_block_number_address"`
	Balance         string `gorm:"size:32"`
}

Account represents the either ERC20 or ETH balances of externally owned accounts in Ethereum at given block The account is considered an eth account and insert to account table if ContractAddress is ETHBytes, or considered an erc20 account and insert to erc20_balance_{ContractAddress} table.

func (Account) TableName

func (a Account) TableName() string

TableName returns the table name of this model

type ERC20

type ERC20 struct {
	BlockNumber int64
	Address     []byte
	TotalSupply string
	Decimals    int
	Name        string
}

ERC20 represents the ERC20 contract

func (ERC20) TableName

func (e ERC20) TableName() string

TableName returns the table name of this model

type Header struct {
	ID          int64
	Hash        []byte
	ParentHash  []byte
	UncleHash   []byte
	Coinbase    []byte
	Root        []byte
	TxHash      []byte
	ReceiptHash []byte
	Difficulty  int64
	Number      int64
	GasLimit    int64
	GasUsed     int64
	Time        int64
	ExtraData   []byte
	MixDigest   []byte
	Nonce       []byte
	// MinerBaseReward plus UnclesInclusionReward plus TxsFee is MinerReward.
	MinerReward           string
	UnclesInclusionReward string
	TxsFee                string
	// Total of uncles reward. At most 2.
	Uncle1Reward   string
	Uncle1Coinbase []byte
	Uncle1Hash     []byte
	Uncle2Reward   string
	Uncle2Coinbase []byte
	Uncle2Hash     []byte

	CreatedAt *time.Time
}

Header represents the header of a block

func (Header) AddReward added in v0.2.3

func (h Header) AddReward(txsFee, minerBaseReward, uncleInclusionReward *big.Int, unclesReward []*big.Int, uncleCBs []common.Address, unclesHash []common.Hash) (*Header, error)

AddReward adds reward to header. Verify that there are at most 2 uncles

func (Header) TableName

func (h Header) TableName() string

TableName returns the table name of this model

type Log

type Log struct {
	TxHash          []byte
	BlockNumber     int64
	ContractAddress []byte
	// The sha3 of the event method
	EventName []byte
	// Indexed parameters of event. At most 3 topics.
	Topic1 []byte
	Topic2 []byte
	Topic3 []byte
	Data   []byte
}

Log represents a receipt log

func (Log) TableName

func (l Log) TableName() string

TableName returns the table name of this model

type QueryParameters added in v0.2.0

type QueryParameters struct {
	Page    uint64
	Limit   uint64
	OrderBy string
	Order   string
}

func (*QueryParameters) OrderString added in v0.2.0

func (q *QueryParameters) OrderString() string

type Receipt

type Receipt struct {
	Root              []byte
	Status            uint
	CumulativeGasUsed int64
	Bloom             []byte
	TxHash            []byte
	ContractAddress   []byte
	GasUsed           int64
	BlockNumber       int64
	Logs              []*Log
}

Receipt represents a transaction receipt

func (Receipt) TableName

func (r Receipt) TableName() string

TableName returns the table name of this model

type Reorg added in v0.3.0

type Reorg struct {
	From      int64
	FromHash  []byte
	To        int64
	ToHash    []byte
	CreatedAt time.Time `deepequal:"-"`
}

Reorg represents the Reorg model

func (Reorg) TableName added in v0.3.0

func (s Reorg) TableName() string

TableName retruns the table name of this Reorg event

type Subscription added in v0.2.0

type Subscription struct {
	ID          int64
	BlockNumber int64
	Group       int64
	Address     []byte
	CreatedAt   time.Time `deepequal:"-"`
	UpdatedAt   time.Time `deepequal:"-"`
}

Subscription represents the Subscription model

func (Subscription) TableName added in v0.2.0

func (s Subscription) TableName() string

TableName retruns the table name of this erc20 contract

type TotalBalance added in v0.2.0

type TotalBalance struct {
	Token        []byte
	BlockNumber  int64
	Group        int64
	Balance      string
	TxFee        string
	MinerReward  string
	UnclesReward string
}

TotalBalance represents the total balance of subscription accounts in different group

func (TotalBalance) TableName added in v0.2.0

func (s TotalBalance) TableName() string

TableName retruns the table name of this model

type TotalDifficulty

type TotalDifficulty struct {
	Block int64
	Hash  []byte
	Td    string
}

TotalDifficulty represents total difficulty for this block

func (TotalDifficulty) TableName

func (t TotalDifficulty) TableName() string

TableName returns the table name of this model

type Transaction

type Transaction struct {
	Hash        []byte
	BlockHash   []byte
	From        []byte
	To          []byte
	Nonce       int64
	GasPrice    int64
	GasLimit    int64
	Amount      string
	Payload     []byte
	BlockNumber int64
}

Transaction represents a transaction

func (Transaction) TableName

func (t Transaction) TableName() string

TableName returns the table name of this model

type Transfer added in v0.2.0

type Transfer struct {
	Address     []byte `gorm:"-"`
	BlockNumber int64  `gorm:"size:8;index"`
	TxHash      []byte `gorm:"size:32;index"`
	From        []byte `gorm:"size:20;index"`
	To          []byte `gorm:"size:20;index"`
	Value       string `gorm:"size:32"`
}

Transfer represents the transfer event in either ether or ERC20 tokens The event is considered an eth transfer event and insert to eth_transfer table if Address is ETHBytes, or considered an erc20 transfer event and insert to erc20_transfer_{Address} table.

func (Transfer) IsMinerRewardEvent added in v0.2.5

func (e Transfer) IsMinerRewardEvent() bool

IsMinerRewardEvent represents a miner or uncle event.

Note that the event is defined by us. It's not a standard ethereum event.

func (Transfer) IsUncleRewardEvent added in v0.2.5

func (e Transfer) IsUncleRewardEvent() bool

IsUncleRewardEvent represents a miner or uncle event.

Note that the event is defined by us. It's not a standard ethereum event.

func (Transfer) TableName added in v0.2.0

func (e Transfer) TableName() string

TableName retruns the table name of this model

Jump to

Keyboard shortcuts

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