model

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: LGPL-3.0 Imports: 6 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
	BlockNumber     int64  `db:"block_number"`
	Address         []byte `db:"address"`
	Balance         string `db:"balance"`
}

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  `db:"block_number"`
	Address     []byte `db:"address"`
	TotalSupply string `db:"total_supply"`
	Decimals    int    `db:"decimals"`
	Name        string `db:"name"`
}

ERC20 represents the ERC20 contract

type Header struct {
	ID          int64  `db:"id"`
	Hash        []byte `db:"hash"`
	ParentHash  []byte `db:"parent_hash"`
	UncleHash   []byte `db:"uncle_hash"`
	Coinbase    []byte `db:"coinbase"`
	Root        []byte `db:"root"`
	TxHash      []byte `db:"tx_hash"`
	ReceiptHash []byte `db:"receipt_hash"`
	Difficulty  int64  `db:"difficulty"`
	Number      int64  `db:"number"`
	GasLimit    int64  `db:"gas_limit"`
	GasUsed     int64  `db:"gas_used"`
	Time        int64  `db:"time"`
	ExtraData   []byte `db:"extra_data"`
	MixDigest   []byte `db:"mix_digest"`
	Nonce       []byte `db:"nonce"`
	// MinerBaseReward plus UnclesInclusionReward plus TxsFee is MinerReward.
	MinerReward           string `db:"miner_reward"`
	UnclesInclusionReward string `db:"uncles_inclusion_reward"`
	TxsFee                string `db:"txs_fee"`
	// Total of uncles reward. At most 2.
	Uncle1Reward   string `db:"uncle1_reward"`
	Uncle1Coinbase []byte `db:"uncle1_coinbase"`
	Uncle1Hash     []byte `db:"uncle1_hash"`
	Uncle2Reward   string `db:"uncle2_reward"`
	Uncle2Coinbase []byte `db:"uncle2_coinbase"`
	Uncle2Hash     []byte `db:"uncle2_hash"`

	CreatedAt *time.Time `db:"created_at"`
}

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

type Log

type Log struct {
	TxHash          []byte `db:"tx_hash"`
	BlockNumber     int64  `db:"block_number"`
	ContractAddress []byte `db:"contract_address"`
	// The sha3 of the event method
	EventName []byte `db:"event_name"`
	// Indexed parameters of event. At most 3 topics.
	Topic1 []byte `db:"topic1"`
	Topic2 []byte `db:"topic2"`
	Topic3 []byte `db:"topic3"`
	Data   []byte `db:"data"`
}

Log represents a receipt log

type QueryParameters added in v0.2.0

type QueryParameters struct {
	Page  uint64
	Limit uint64
}

type Receipt

type Receipt struct {
	Root              []byte `db:"root"`
	Status            uint   `db:"status"`
	CumulativeGasUsed int64  `db:"cumulative_gas_used"`
	Bloom             []byte `db:"bloom"`
	TxHash            []byte `db:"tx_hash"`
	ContractAddress   []byte `db:"contract_address"`
	GasUsed           int64  `db:"gas_used"`
	BlockNumber       int64  `db:"block_number"`
	Logs              []*Log
}

Receipt represents a transaction receipt

type Reorg added in v0.3.0

type Reorg struct {
	From      int64     `db:"from"`
	FromHash  []byte    `db:"from_hash"`
	To        int64     `db:"to"`
	ToHash    []byte    `db:"to_hash"`
	CreatedAt time.Time `db:"created_at" deepequal:"-"`
}

Reorg represents the Reorg model

type Subscription added in v0.2.0

type Subscription struct {
	ID          int64     `db:"id"`
	BlockNumber int64     `db:"block_number"`
	Group       int64     `db:"group"`
	Address     []byte    `db:"address"`
	CreatedAt   time.Time `db:"created_at" deepequal:"-"`
	UpdatedAt   time.Time `db:"updated_at" deepequal:"-"`
}

Subscription represents the Subscription model

type TotalBalance added in v0.2.0

type TotalBalance struct {
	Token        []byte `db:"token"`
	BlockNumber  int64  `db:"block_number"`
	Group        int64  `db:"group"`
	Balance      string `db:"balance"`
	TxFee        string `db:"tx_fee"`
	MinerReward  string `db:"miner_reward"`
	UnclesReward string `db:"uncles_reward"`
}

TotalBalance represents the total balance of subscription accounts in different group

type TotalDifficulty

type TotalDifficulty struct {
	Block int64  `db:"block"`
	Hash  []byte `db:"hash"`
	Td    string `db:"td"`
}

TotalDifficulty represents total difficulty for this block

type Transaction

type Transaction struct {
	Hash        []byte `db:"hash"`
	BlockHash   []byte `db:"block_hash"`
	From        []byte `db:"from"`
	To          []byte `db:"to"`
	Nonce       int64  `db:"nonce"`
	GasPrice    int64  `db:"gas_price"`
	GasLimit    int64  `db:"gas_limit"`
	Amount      string `db:"amount"`
	Payload     []byte `db:"payload"`
	BlockNumber int64  `db:"block_number"`
}

Transaction represents a transaction

type Transfer added in v0.2.0

type Transfer struct {
	Address     []byte
	BlockNumber int64  `db:"block_number"`
	TxHash      []byte `db:"tx_hash"`
	From        []byte `db:"from"`
	To          []byte `db:"to"`
	Value       string `db:"value"`
}

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