models

package
v0.0.0-...-65a0283 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BLOCKS        = "blocks"
	TRANSACTIONS  = "transactions"
	ITRANSACTIONS = "itransactions"
	UNCLES        = "uncles"
	CONTRACTS     = "contracts"
	CONTRACTCALLS = "contractcalls"
	TRANSFERS     = "tokentransfers"
	FORKEDBLOCKS  = "forkedblocks"
	CHARTS        = "charts"
	STORE         = "sysstores"
	ENODES        = "enodes"
	ACCOUNTS      = "accounts"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Address string `bson:"address" json:"address"`
	Balance string `bson:"balance" json:"balance"`
	Block   uint64 `bson:"block" json:"block"`
}

type Block

type Block struct {
	Number          uint64           `bson:"number" json:"number"`
	Timestamp       uint64           `bson:"timestamp" json:"timestamp"`
	Transactions    []Transaction    `bson:"transactions" json:"transactions"`
	RawTransactions []RawTransaction `bson:"-" json:"-"`
	TokenTransfers  int              `bson:"tokenTransfers" json:"tokenTransfers"`
	Hash            string           `bson:"hash" json:"hash"`
	ParentHash      string           `bson:"parentHash" json:"parentHash"`
	Sha3Uncles      string           `bson:"sha3Uncles" json:"sha3Uncles"`
	Miner           string           `bson:"miner" json:"miner"`
	Difficulty      string           `bson:"difficulty" json:"difficulty"`
	TotalDifficulty string           `bson:"totalDifficulty" json:"totalDifficulty"`
	Size            uint64           `bson:"size" json:"size"`
	GasUsed         uint64           `bson:"gasUsed" json:"gasUsed"`
	GasLimit        uint64           `bson:"gasLimit" json:"gasLimit"`
	Nonce           string           `bson:"nonce" json:"nonce"`
	// Same as Txs
	Uncles  []string `bson:"-" json:"-"`
	UncleNo int      `bson:"uncles" json:"uncles"`
	// TODO: Should these be strings
	// Maybe make this more clear // minted = baseBlockReward + uncleRewards? + bonusRewardForUncles?
	BlockReward  string `bson:"blockReward" json:"blockReward"`
	UncleRewards string `bson:"uncleRewards" json:"uncleRewards"`
	AvgGasPrice  string `bson:"avgGasPrice" json:"avgGasPrice"`
	TxFees       string `bson:"txFees" json:"txFees"`
	// Supply
	Minted string `bson:"minted" json:"minted"`
	Supply string `bson:"supply" json:"supply"`
	//
	ExtraData     string `bson:"extraData" json:"extraData"`
	BaseFeePerGas string `bson:"baseFeePerGas" json:"baseFeePerGas,omitempty"`
	Burned        string `bson:"burned" json:"burned,omitempty"`
	TotalBurned   string `bson:"totalBurned" json:"totalBurned,omitempty"`
	//
	Trace []BlockTrace `bson:"trace" json:"trace,omitempty"`
	//
	ITransactions []ITransaction `bson:"iTransactions" json:"iTransactions,omitempty"`
}

type BlockTrace

type BlockTrace struct {
	Failed      bool        `bson:"failed" json:"failed"`
	Gas         uint64      `bson:"gas" json:"gas"`
	ReturnValue string      `bson:"returnValue" json:"returnValue"`
	StructLogs  []StructLog `bson:"structLogs" json:"structLogs"`
}

type Enode

type Enode struct {
	Id   enode.ID `json:"id"`
	Ip   net.IP   `json:"ip"`
	Name string   `json:"name"`
	TCP  int      `json:"tcp"`
	UDP  int      `json:"udp"`
}

type ITransaction

type ITransaction struct {
	ParentHash  string         `json:"parentHash,omitempty" bson:"parentHash,omitempty"`
	BlockNumber uint64         `json:"blockNumber,omitempty" bson:"blockNumber,omitempty"`
	Type        string         `json:"type" bson:"type"`
	From        string         `json:"from" bson:"from"`
	To          string         `json:"to" bson:"to"`
	Value       string         `json:"value,omitempty" bson:"value,omitempty"` //convert to number -> string
	Gas         string         `json:"gas" bson:"gas"`                         //convert to number -> string
	GasUsed     string         `json:"gasUsed" bson:"gasUsed"`                 //convert to number -> string
	Input       string         `json:"input" bson:"input"`
	Output      string         `json:"output" bson:"output"`
	Calls       []ITransaction `json:"calls,omitempty" bson:"calls,omitempty"`
}

ITransaction the schema representing internal transactions

type MultiSeriesChart

type MultiSeriesChart struct {
	Name       string                `bson:"name" json:"name"`
	Datasets   []*MultiSeriesDataset `bson:"datasets" json:"datasets"`
	Timestamps []string              `bson:"timestamps" json:"timestamps"`
}

type MultiSeriesDataset

type MultiSeriesDataset struct {
	Name       string   `bson:"name" json:"name"`
	Series     []uint   `bson:"series" json:"series"`
	Timestamps []string `bson:"timestamps" json:"timestamps"`
}

func (MultiSeriesDataset) Len

func (msd MultiSeriesDataset) Len() int

func (*MultiSeriesDataset) SliceTime

func (msd *MultiSeriesDataset) SliceTime(daysBack int)

type NumberChart

type NumberChart struct {
	Name       string   `bson:"name" json:"name"`
	Series     []uint64 `bson:"series" json:"series"`
	Timestamps []string `bson:"timestamps" json:"timestamps"`
}

type NumberStringChart

type NumberStringChart struct {
	Name       string   `bson:"name" json:"name"`
	Series     []string `bson:"series" json:"series"`
	Timestamps []string `bson:"timestamps" json:"timestamps"`
}

type RawBlock

type RawBlock struct {
	//TODO: For indexing purposes "number" should be renamed to "blockNumber"?
	Number          string           `bson:"number" json:"number"`
	Timestamp       string           `bson:"timestamp" json:"timestamp"`
	Transactions    []RawTransaction `bson:"transactions" json:"transactions"`
	Hash            string           `bson:"hash" json:"hash"`
	ParentHash      string           `bson:"parentHash" json:"parentHash"`
	Sha3Uncles      string           `bson:"sha3Uncles" json:"sha3Uncles"`
	Miner           string           `bson:"miner" json:"miner"`
	Difficulty      string           `bson:"difficulty" json:"difficulty"`
	TotalDifficulty string           `bson:"totalDifficulty" json:"totalDifficulty"`
	Size            string           `bson:"size" json:"size"`
	GasUsed         string           `bson:"gasUsed" json:"gasUsed"`
	GasLimit        string           `bson:"gasLimit" json:"gasLimit"`
	Nonce           string           `bson:"nonce" json:"nonce"`
	Uncles          []string         `bson:"uncles" json:"uncles"`
	//TODO: These are not used for anything
	BlockReward   string `bson:"blockReward" json:"blockReward"`
	UnclesRewards string `bson:"unclesReward" json:"unclesReward"`
	AvgGasPrice   string `bson:"avgGasPrice" json:"avgGasPrice"`
	TxFees        string `bson:"txFees" json:"txFees"`
	//
	ExtraData     string `bson:"extraData" json:"extraData"`
	BaseFeePerGas string `bson:"baseFeePerGas" json:"baseFeePerGas,omitempty"`
	Burned        string `bson:"burned" json:"burned,omitempty"`
	TotalBurned   string `bson:"totalBurned" json:"totalBurned,omitempty"`
}

func (*RawBlock) Convert

func (b *RawBlock) Convert() Block

type RawBlockDetails

type RawBlockDetails struct {
	Number string `bson:"number" json:"number"`
	Hash   string `bson:"hash" json:"hash"`
}

func (*RawBlockDetails) Convert

func (rbn *RawBlockDetails) Convert() (uint64, string)

type RawBlockTrace

type RawBlockTrace struct {
	Result BlockTrace `bson:"result" json:"result,omitempty"`
}

func (*RawBlockTrace) Convert

func (rbt *RawBlockTrace) Convert() BlockTrace

type RawState

type RawState struct {
	Root     string                 `bson:"root" json:"root"`
	Accounts map[string]interface{} `bson:"accounts" json:"accounts"`
}

type RawTransaction

type RawTransaction struct {
	BlockHash            string `json:"blockHash"`
	BlockNumber          string `json:"blockNumber"`
	From                 string `json:"from"`
	Gas                  string `json:"gas"`
	GasPrice             string `json:"gasPrice"`
	Hash                 string `json:"hash"`
	Input                string `json:"input"`
	Nonce                string `json:"nonce"`
	To                   string `json:"to"`
	TransactionIndex     string `json:"transactionIndex"`
	Value                string `json:"value"`
	V                    string `json:"v"`
	R                    string `json:"r"`
	S                    string `json:"s"`
	MaxFeePerGas         string `bson:"maxFeePerGas" json:"maxFeePerGas,omitempty"`
	MaxPriorityFeePerGas string `bson:"maxPriorityFeePerGas" json:"maxPriorityFeePerGas,omitempty"`
	Type                 string `bson:"type" json:"type,omitempty"`
	BaseFeePerGas        string `bson:"baseFeePerGas" json:"baseFeePerGas,omitempty"`
}

func (*RawTransaction) Convert

func (rt *RawTransaction) Convert() Transaction

type RawTxReceipt

type RawTxReceipt struct {
	BlockHash         string  `json:"blockHash"`
	BlockNumber       string  `json:"blockNumber"`
	ContractAddress   string  `json:"contractAddress"`
	CumulativeGasUsed string  `json:"cumulativeGasUsed"`
	From              string  `json:"from"`
	GasUsed           string  `json:"gasUsed"`
	Logs              []TxLog `json:"logs"`
	LogsBloom         string  `json:"logsBloom"`
	Status            string  `json:"status"`
	To                string  `json:"to"`
	TransactionHash   string  `json:"transactionHash"`
	TransactionIndex  string  `json:"transactionIndex"`
}

func (*RawTxReceipt) Convert

func (rtr *RawTxReceipt) Convert() TxReceipt

type RawTxTrace

type RawTxTrace struct {
	Type    string       `json:"type"`
	From    string       `json:"from"`
	To      string       `json:"to"`
	Value   string       `json:"value,omitempty"` // hex
	Gas     string       `json:"gas"`             // hex
	GasUsed string       `json:"gasUsed"`         // hex
	Input   string       `json:"input"`
	Output  string       `json:"output"`
	Time    string       `json:"-"`
	Calls   []RawTxTrace `json:"calls,omitempty"`
}

RawTxTrace is what we get from the node tracer

func (*RawTxTrace) Convert

func (rtt *RawTxTrace) Convert() ITransaction

type RawUncle

type RawUncle struct {
	Number      string `bson:"number" json:"number"`
	Position    string `bson:"position" json:"position"`
	BlockNumber string `bson:"blockNumber" json:"blockNumber"`
	Hash        string `bson:"hash" json:"hash"`
	ParentHash  string `bson:"parentHash" json:"parentHash"`
	Sha3Uncles  string `bson:"sha3Uncles" json:"sha3Uncles"`
	Miner       string `bson:"miner" json:"miner"`
	Difficulty  string `bson:"difficulty" json:"difficulty"`
	GasUsed     string `bson:"gasUsed" json:"gasUsed"`
	GasLimit    string `bson:"gasLimit" json:"gasLimit"`
	Timestamp   string `bson:"timestamp" json:"timestamp"`
	Reward      string `bson:"reward" json:"reward"`
}

func (*RawUncle) Convert

func (rw *RawUncle) Convert() Uncle

type Store

type Store struct {
	Symbol string `bson:"symbol" json:"symbol"`

	Timestamp   int64  `bson:"updated" json:"updated"`
	Supply      string `bson:"supply" json:"supply"`
	LatestBlock Block  `bson:"latestBlock" json:"latestBlock"`

	LatestTraceHash string `json:"latestTraceHash" bson:"latestTraceHash"`

	TotalTransactions      int64 `bson:"totalTransactions" json:"totalTransactions"`
	TotalContractsDeployed int64 `bson:"totalContractsDeployed" json:"totalContractsDeployed"`
	TotalContractCalls     int64 `bson:"totalContractCalls" json:"totalContractCalls"`
	TotalTokenTransfers    int64 `bson:"totalTokenTransfers" json:"totalTokenTransfers"`
	TotalForkedBlocks      int64 `bson:"totalForkedBlocks" json:"totalForkedBlocks"`
	TotalUncles            int64 `bson:"totalUncles" json:"totalUncles"`
}

type StructLog

type StructLog struct {
	Depth   uint64   `bson:"depth" json:"depth"`
	Gas     uint64   `bson:"gas" json:"gas"`
	GasCost uint64   `bson:"gasCost" json:"gasCost"`
	Op      string   `bson:"op" json:"op"`
	Pc      uint64   `bson:"pc" json:"pc"`
	Stack   []string `bson:"stack" json:"stack"`
}

type TokenTransfer

type TokenTransfer struct {
	BlockNumber uint64 `bson:"blockNumber" json:"blockNumber"`
	Hash        string `bson:"hash" json:"hash"`
	Timestamp   uint64 `bson:"timestamp" json:"timestamp"`
	From        string `bson:"from" json:"from"`
	To          string `bson:"to" json:"to"`
	Value       string `bson:"value" json:"value"`
	Contract    string `bson:"contract" json:"contract"`
	Method      string `bson:"method" json:"method"`
	Status      bool   `json:"status"`
	// If the token can't be recognized we give it "unknown" method and attach the input data
	Data string `json:"data,omitempty" bson:"data,omitempty"`
}

type Transaction

type Transaction struct {
	BlockHash        string `bson:"blockHash" json:"blockHash"`
	BlockNumber      uint64 `bson:"blockNumber" json:"blockNumber"`
	Hash             string `bson:"hash" json:"hash"`
	Timestamp        uint64 `bson:"timestamp" json:"timestamp"`
	Input            string `bson:"input" json:"input"`
	Value            string `bson:"value" json:"value"`
	Gas              uint64 `bson:"gas" json:"gas"`
	GasPrice         uint64 `bson:"gasPrice" json:"gasPrice"`
	Nonce            string `bson:"nonce" json:"nonce"`
	TransactionIndex uint64 `bson:"transactionIndex" json:"transactionIndex"`
	From             string `bson:"from" json:"from"`
	To               string `bson:"to" json:"to"`
	Status           bool   `json:"status"`
	//
	GasUsed         uint64  `bson:"gasUsed" json:"gasUsed"`
	ContractAddress string  `bson:"contractAddress" json:"contractAddress"`
	Logs            []TxLog `bson:"logs" json:"logs"`
	//
	MaxFeePerGas         uint64 `bson:"maxFeePerGas" json:"maxFeePerGas,omitempty"`
	MaxPriorityFeePerGas uint64 `bson:"maxPriorityFeePerGas" json:"maxPriorityFeePerGas,omitempty"`
	Type                 string `bson:"type" json:"type,omitempty"`
	BaseFeePerGas        string `bson:"baseFeePerGas" json:"baseFeePerGas,omitempty"`
	//
	Trace ITransaction `bson:"trace,omitempty" json:"trace,omitempty"`
	//
	ITransactions []ITransaction `bson:"iTransactions" json:"iTransactions,omitempty"`
}

func (*Transaction) GetTokenTransfer

func (tx *Transaction) GetTokenTransfer() *TokenTransfer

func (*Transaction) IsContractCall

func (tx *Transaction) IsContractCall() bool

generic function call on contract that is not a token transfer

func (*Transaction) IsContractDeployTxn

func (tx *Transaction) IsContractDeployTxn() bool

func (*Transaction) IsTokenTransfer

func (tx *Transaction) IsTokenTransfer() bool

type TxLog

type TxLog struct {
	Address          string   `bson:"address" json:"address"`
	Topics           []string `bson:"topics" json:"topics"`
	Data             string   `bson:"data" json:"data"`
	BlockNumber      string   `bson:"blockNumber" json:"blockNumber"`
	TransactionIndex string   `bson:"transactionIndex" json:"transactionIndex"`
	TransactionHash  string   `bson:"transactionHash" json:"transactionHash"`
	BlockHash        string   `bson:"blockHash" json:"blockHash"`
	LogIndex         string   `bson:"logIndex" json:"logIndex"`
	Removed          bool     `bson:"removed" json:"removed"`
}

type TxReceipt

type TxReceipt struct {
	BlockHash         string  `json:"blockHash"`
	BlockNumber       uint64  `json:"blockNumber"`
	ContractAddress   string  `json:"contractAddress"`
	CumulativeGasUsed uint64  `json:"cumulativeGasUsed"`
	From              string  `json:"from"`
	GasUsed           uint64  `json:"gasUsed"`
	Logs              []TxLog `json:"logs"`
	LogsBloom         string  `json:"logsBloom"`
	Status            bool    `json:"status"`
	To                string  `json:"to"`
	TransactionHash   string  `json:"transactionHash"`
	TransactionIndex  string  `json:"transactionIndex"`
}

type Uncle

type Uncle struct {
	Number      uint64 `bson:"number" json:"number"`
	Position    uint64 `bson:"position" json:"position"`
	BlockNumber uint64 `bson:"blockNumber" json:"blockNumber"`
	Hash        string `bson:"hash" json:"hash"`
	ParentHash  string `bson:"parentHash" json:"parentHash"`
	Sha3Uncles  string `bson:"sha3Uncles" json:"sha3Uncles"`
	Miner       string `bson:"miner" json:"miner"`
	Difficulty  string `bson:"difficulty" json:"difficulty"`
	GasUsed     uint64 `bson:"gasUsed" json:"gasUsed"`
	GasLimit    uint64 `bson:"gasLimit" json:"gasLimit"`
	Timestamp   uint64 `bson:"timestamp" json:"timestamp"`
	Reward      string `bson:"reward" json:"reward"`
}

Jump to

Keyboard shortcuts

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