db

package
v0.0.0-...-6dd2e59 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArkeoContract

type ArkeoContract struct {
	Entity
	ProviderID     int64              `db:"provider_id"`
	DelegatePubkey string             `db:"delegate_pubkey"`
	ClientPubkey   string             `db:"client_pubkey"`
	Height         int64              `db:"height"`
	ContractType   types.ContractType `db:"contract_type"`
	Duration       int64              `db:"duration"`
	Rate           int64              `db:"rate"`
	OpenCost       int64              `db:"open_cost"`
	ClosedHeight   int64              `db:"closed_height"`
}

type ArkeoProvider

type ArkeoProvider struct {
	Entity `json:"-"`
	Pubkey string `db:"pubkey"`
	Chain  string `db:"chain"`
	// this is a DECIMAL type in the db
	Bond                string               `db:"bond"`
	MetadataURI         string               `db:"metadata_uri"`
	MetadataNonce       uint64               `db:"metadata_nonce"`
	Status              types.ProviderStatus `db:"status,text"`
	MinContractDuration int64                `db:"min_contract_duration"`
	MaxContractDuration int64                `db:"max_contract_duration"`
	SubscriptionRate    int64                `db:"subscription_rate"`
	PayAsYouGoRate      int64                `db:"paygo_rate"`
}

type Block

type Block struct {
	Entity
	Height    int64     `db:"height"`
	Hash      string    `db:"hash"`
	BlockTime time.Time `db:"block_time"`
}

type BlockGap

type BlockGap struct {
	Start int64 `db:"gap_start"`
	End   int64 `db:"gap_end"`
}

func (BlockGap) String

func (g BlockGap) String() string

type DBConfig

type DBConfig struct {
	Host         string
	Port         uint
	User         string
	Pass         string
	DBName       string
	PoolMaxConns int
	PoolMinConns int
	SSLMode      string
}

type DirectoryDB

type DirectoryDB struct {
	// contains filtered or unexported fields
}

func New

func New(config DBConfig) (*DirectoryDB, error)

func (*DirectoryDB) CloseContract

func (d *DirectoryDB) CloseContract(contractID int64, height int64) (*Entity, error)

func (*DirectoryDB) FindBlockGaps

func (d *DirectoryDB) FindBlockGaps() ([]*BlockGap, error)

func (*DirectoryDB) FindContract

func (d *DirectoryDB) FindContract(providerID int64, delegatePubkey string, height int64) (*ArkeoContract, error)

func (*DirectoryDB) FindContractByPubKeys

func (d *DirectoryDB) FindContractByPubKeys(chain string, providerPubkey string, delegatePubkey string, height int64) (*ArkeoContract, error)

func (*DirectoryDB) FindContractsByPubKeys

func (d *DirectoryDB) FindContractsByPubKeys(chain string, providerPubkey string, delegatePubkey string) ([]*ArkeoContract, error)

func (*DirectoryDB) FindIndexerStatus

func (d *DirectoryDB) FindIndexerStatus(id int64) (*IndexerStatus, error)

func (*DirectoryDB) FindLatestBlock

func (d *DirectoryDB) FindLatestBlock() (*Block, error)

func (*DirectoryDB) FindProvider

func (d *DirectoryDB) FindProvider(pubkey string, chain string) (*ArkeoProvider, error)

func (*DirectoryDB) GetArkeoNetworkStats

func (d *DirectoryDB) GetArkeoNetworkStats() (*types.ArkeoStats, error)

func (*DirectoryDB) InsertBlock

func (d *DirectoryDB) InsertBlock(b *Block) (*Entity, error)

func (*DirectoryDB) InsertBondProviderEvent

func (d *DirectoryDB) InsertBondProviderEvent(providerID int64, evt types.BondProviderEvent) (*Entity, error)

func (*DirectoryDB) InsertModProviderEvent

func (d *DirectoryDB) InsertModProviderEvent(providerID int64, evt types.ModProviderEvent) (*Entity, error)

func (*DirectoryDB) InsertProvider

func (d *DirectoryDB) InsertProvider(provider *ArkeoProvider) (*Entity, error)

func (*DirectoryDB) SearchProviders

func (d *DirectoryDB) SearchProviders(criteria types.ProviderSearchParams) ([]*ArkeoProvider, error)

func (*DirectoryDB) UpdateIndexerStatus

func (d *DirectoryDB) UpdateIndexerStatus(indexerStatus *IndexerStatus) (*Entity, error)

func (*DirectoryDB) UpdateProvider

func (d *DirectoryDB) UpdateProvider(provider *ArkeoProvider) (*Entity, error)

func (*DirectoryDB) UpsertCloseContractEvent

func (d *DirectoryDB) UpsertCloseContractEvent(contractID int64, evt types.CloseContractEvent) (*Entity, error)

func (*DirectoryDB) UpsertContract

func (d *DirectoryDB) UpsertContract(providerID int64, evt types.OpenContractEvent) (*Entity, error)

func (*DirectoryDB) UpsertContractSettlementEvent

func (d *DirectoryDB) UpsertContractSettlementEvent(contractID int64, evt types.ContractSettlementEvent) (*Entity, error)

func (*DirectoryDB) UpsertIndexerStatus

func (d *DirectoryDB) UpsertIndexerStatus(indexerStatus *IndexerStatus) (*Entity, error)

func (*DirectoryDB) UpsertOpenContractEvent

func (d *DirectoryDB) UpsertOpenContractEvent(contractID int64, evt types.OpenContractEvent) (*Entity, error)

func (*DirectoryDB) UpsertProviderMetadata

func (d *DirectoryDB) UpsertProviderMetadata(providerID int64, data sentinel.Metadata) (*Entity, error)

func (*DirectoryDB) UpsertValidatorPayoutEvent

func (d *DirectoryDB) UpsertValidatorPayoutEvent(evt types.ValidatorPayoutEvent) (*Entity, error)

type Entity

type Entity struct {
	ID      int64     `db:"id"`
	Created time.Time `db:"created"`
	Updated time.Time `db:"updated"`
}

base entity for db types

type IndexerStatus

type IndexerStatus struct {
	ID     int64  `db:"id"`
	Height uint64 `db:"height"`
}

Jump to

Keyboard shortcuts

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