index

package
v0.0.0-...-8c5539c Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BackfillChains           = make(map[string]uint64)
	BackfillLastCheckedMutex sync.Mutex
)
View Source
var (
	LastCheckedChains = make(map[string]uint64)
	LastCheckedMutex  sync.Mutex
)

Functions

func BackFillChains

func BackFillChains(ctx context.Context, Clients map[string]*ethclient.Client, mode string)

BackFillChains indexes all txs in all blocks per chain

func BackfillChainPersister

func BackfillChainPersister(ctx context.Context, chain string) error

func ChainPersister

func ChainPersister(ctx context.Context, chain string) error

func CleanShutdownWithError

func CleanShutdownWithError(err error, message string)

func GetTokenIDsForContract

func GetTokenIDsForContract(contract string, chain string) []int64

func HandleGetCurrentHoldersOfContract

func HandleGetCurrentHoldersOfContract(w http.ResponseWriter, r *http.Request)

func HandleGetTokenIDsByContract

func HandleGetTokenIDsByContract(w http.ResponseWriter, r *http.Request)

func HandleGetTransactionByID

func HandleGetTransactionByID(w http.ResponseWriter, r *http.Request)

func HandleGetTransactionsByContract

func HandleGetTransactionsByContract(w http.ResponseWriter, r *http.Request)

HandleGetTransactionsByContract returns all transactions for a contract

func HandleGetTransactionsReceivedByAddress

func HandleGetTransactionsReceivedByAddress(w http.ResponseWriter, r *http.Request)

HandleGetTransactionsReceivedByAddress returns all transactions received by an address

func HandleGetTransactionsSentFromAddress

func HandleGetTransactionsSentFromAddress(w http.ResponseWriter, r *http.Request)

HandleGetTransactionsSentFromAddress returns all transactions received by an address

func IndexChains

func IndexChains(ctx context.Context, Clients map[string]*ethclient.Client, mode string)

IndexChains indexes all txs in all blocks per chain

func IndexTx

func IndexTx(chain string, tx types.Transaction, blockData string) error

func PersistLastChecked

func PersistLastChecked(chain string) error

func PersistLastCheckedBackfill

func PersistLastCheckedBackfill(chain string) error

func Rescheduler

func Rescheduler(ctx context.Context, chain string)

func TokenIDFromTransaction

func TokenIDFromTransaction(c *ethclient.Client, r *types.Receipt) (*big.Int, error)

Types

type BlockJob

type BlockJob struct {
	ChainID     string
	BlockNumber uint64
}

type ChainState

type ChainState struct {
	gorm.Model
	ChainID          string `gorm:"uniqueIndex,not null"`
	LastCheckedBlock uint64
}

ChainState contains the index state of the chain

func (*ChainState) GetLastCheckedBlock

func (cs *ChainState) GetLastCheckedBlock() uint64

GetLastCheckedBlock returns the last checked block number for the defined chain

func (*ChainState) GetLastSoftCheckedBlock

func (cs *ChainState) GetLastSoftCheckedBlock() uint64

GetLastSoftCheckedBlock returns the last checked block number for the defined chain from either the database or queue, optimistically assuming that the queue will be worked

func (*ChainState) IncrementLastCheckedBlock

func (cs *ChainState) IncrementLastCheckedBlock() error

IncrementLastCheckedBlock sets the last checked block number for the defined chain if it is larger than current

func (*ChainState) IncrementLocalLastCheckedBlock

func (cs *ChainState) IncrementLocalLastCheckedBlock() error

IncrementLocalLastCheckedBlock sets the last checked block number for the defined chain if it is larger than current

func (*ChainState) UpdateLastCheckedBlock

func (cs *ChainState) UpdateLastCheckedBlock()

UpdateLastCheckedBlock sets the last checked block number for the defined chain

type ChainStateBackfill

type ChainStateBackfill struct {
	gorm.Model
	ChainID          string `gorm:"uniqueIndex,not null"`
	EndBlock         uint64
	LastCheckedBlock uint64
}

ChainStateBackfill contains the index state of the chain

func (*ChainStateBackfill) Get

func (*ChainStateBackfill) GetLastCheckedBlock

func (b *ChainStateBackfill) GetLastCheckedBlock() uint64

GetLastCheckedBlock returns the last checked block number for the defined chain

func (*ChainStateBackfill) GetLastSoftCheckedBlock

func (cs *ChainStateBackfill) GetLastSoftCheckedBlock() uint64

GetLastSoftCheckedBlock returns the last checked block number for the defined chain from either the database or queue, optimistically assuming that the queue will be worked

func (*ChainStateBackfill) UpdateLastCheckedBlock

func (b *ChainStateBackfill) UpdateLastCheckedBlock() error

UpdateLastCheckedBlock sets the last checked block number for the defined chain

func (*ChainStateBackfill) UpdateLocalLastCheckedBlock

func (cs *ChainStateBackfill) UpdateLocalLastCheckedBlock() error

UpdateLocalLastCheckedBlock sets the last checked block number for the defined chain if it is larger than current

type ContractHolder

type ContractHolder struct {
	Address       string  `json:"address"`
	SenderAddress string  `json:"-"`
	Value         uint64  `json:"value"`
	TokenIDs      []int64 `json:"token_ids"`
}

ContractHolder is a holder of a contract

func GetCurrentHoldersOfContract

func GetCurrentHoldersOfContract(contract string, chain string, tokenID int64) ([]*ContractHolder, error)

type IndexJob

type IndexJob struct {
	Chain       string
	BlockData   string
	Transaction *types.Transaction
}

IndexJob contains a single transaction index job

type Transaction

type Transaction struct {
	gorm.Model
	Time            int64
	ChainHash       string `gorm:"uniqueIndex,not null"`
	ChainID         string `` /* 169-byte string literal not displayed */
	Status          uint64 `gorm:"type:numeric"`
	BlockNumber     int64
	Hash            string `gorm:"uniqueIndex:idx_chain_id_addrs;uniqueIndex:idx_chain_id_contract_to_addr"`
	ToAddr          string `gorm:"uniqueIndex:idx_chain_id_addrs;index:idx_chain_id_contract_addr2;index:idx_chain_id_to_addr"`
	FromAddr        string `gorm:"uniqueIndex:idx_chain_id_addrs;index:idx_chain_id_from_addr"`
	Value           int64
	Gas             int64
	GasPrice        int64
	ContractToAddr  string `gorm:"uniqueIndex:idx_chain_id_addrs;uniqueIndex:idx_chain_id_contract_to_addr;index:idx_chain_id_contract_addr2"`
	ContractValue   uint64 `gorm:"type:numeric"`
	ContractTokenID int64
	Data            []byte `json:"-" gorm:"-"`
}

Transaction represents a single indexed transaction

func GetTransactionByID

func GetTransactionByID(chain string, txid string, cached bool) []Transaction

GetTransactionByID returns all transactions for an ID

func GetTransactionsByContract

func GetTransactionsByContract(contract string, chain string, tokenID int64) []Transaction

GetTransactionsByContract returns all transactions for a contract

func GetTransactionsByContractPager

func GetTransactionsByContractPager(contract string, chain string, tokenID int64, cached bool, page int, pageSize int) []Transaction

GetTransactionsByContractPager returns all transactions for a contract

func GetTransactionsReceivedByAddress

func GetTransactionsReceivedByAddress(address string, chain string, page int, pageSize int, order string) []Transaction

GetTransactionsReceivedByAddress returns all transactions for a contract

func GetTransactionsSentFromAddress

func GetTransactionsSentFromAddress(address string, chain string, page int, pageSize int, order string) []Transaction

GetTransactionsSentFromAddress returns all transactions for a contract

func (*Transaction) Index

func (t *Transaction) Index() error

Index indexes the transactions in the given block

Jump to

Keyboard shortcuts

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