Documentation
¶
Index ¶
- Variables
- type ContractBilling
- type DBContract
- type Database
- type Farm
- type Node
- type NodePower
- type NodesDistribution
- type PostgresDatabase
- func (d *PostgresDatabase) Close() error
- func (p *PostgresDatabase) DeleteOldGpus(ctx context.Context, nodeTwinIds []uint32, expiration int64) error
- func (d *PostgresDatabase) GetConnectionString() string
- func (d *PostgresDatabase) GetContract(ctx context.Context, contractID uint32) (DBContract, error)
- func (d *PostgresDatabase) GetContractBills(ctx context.Context, contractID uint32, limit types.Limit) ([]ContractBilling, uint, error)
- func (d *PostgresDatabase) GetContracts(ctx context.Context, filter types.ContractFilter, limit types.Limit) ([]DBContract, uint, error)
- func (d *PostgresDatabase) GetContractsLatestBillReports(ctx context.Context, contractsIds []uint32, limit uint) ([]ContractBilling, error)
- func (d *PostgresDatabase) GetContractsTotalBilledAmount(ctx context.Context, contractIds []uint32) (uint64, error)
- func (d *PostgresDatabase) GetFarm(ctx context.Context, farmID uint32) (Farm, error)
- func (d *PostgresDatabase) GetFarms(ctx context.Context, filter types.FarmFilter, limit types.Limit) ([]Farm, uint, error)
- func (p *PostgresDatabase) GetHealthyNodeTwinIds(ctx context.Context) ([]uint32, error)
- func (p *PostgresDatabase) GetLastNodeTwinID(ctx context.Context) (uint32, error)
- func (d *PostgresDatabase) GetLastUpsertsTimestamp() (types.IndexersState, error)
- func (d *PostgresDatabase) GetNode(ctx context.Context, nodeID uint32) (Node, error)
- func (p *PostgresDatabase) GetNodeTwinIDsAfter(ctx context.Context, twinID uint32) ([]uint32, error)
- func (d *PostgresDatabase) GetNodes(ctx context.Context, filter types.NodeFilter, limit types.Limit) ([]Node, uint, error)
- func (d *PostgresDatabase) GetPublicIps(ctx context.Context, filter types.PublicIpFilter, limit types.Limit) ([]types.PublicIP, uint, error)
- func (d *PostgresDatabase) GetRandomHealthyTwinIds(length int) ([]uint32, error)
- func (d *PostgresDatabase) GetStats(ctx context.Context, filter types.StatsFilter) (types.Stats, error)
- func (d *PostgresDatabase) GetTwins(ctx context.Context, filter types.TwinFilter, limit types.Limit) ([]types.Twin, uint, error)
- func (d *PostgresDatabase) Initialize() error
- func (d *PostgresDatabase) Initialized() error
- func (d *PostgresDatabase) Ping() error
- func (p *PostgresDatabase) UpsertCpuBenchmark(ctx context.Context, cpuBenchmarks []types.CpuBenchmark) error
- func (p *PostgresDatabase) UpsertNetworkSpeed(ctx context.Context, speeds []types.Speed) error
- func (p *PostgresDatabase) UpsertNodeDmi(ctx context.Context, dmis []types.Dmi) error
- func (p *PostgresDatabase) UpsertNodeFeatures(ctx context.Context, features []types.NodeFeatures) error
- func (p *PostgresDatabase) UpsertNodeHealth(ctx context.Context, healthReports []types.HealthReport) error
- func (p *PostgresDatabase) UpsertNodeIpv6Report(ctx context.Context, ips []types.HasIpv6) error
- func (p *PostgresDatabase) UpsertNodeLocation(ctx context.Context, locations []types.NodeLocation) error
- func (p *PostgresDatabase) UpsertNodeWorkloads(ctx context.Context, workloads []types.NodesWorkloads) error
- func (p *PostgresDatabase) UpsertNodesGPU(ctx context.Context, gpus []types.NodeGPU) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNodeNotFound node not found ErrNodeNotFound = errors.New("node not found") // ErrFarmNotFound farm not found ErrFarmNotFound = errors.New("farm not found") // ErrViewNotFound ErrResourcesCacheTableNotFound = errors.New("ERROR: relation \"resources_cache\" does not exist (SQLSTATE 42P01)") // ErrContractNotFound contract not found ErrContractNotFound = errors.New("contract not found") )
Functions ¶
This section is empty.
Types ¶
type ContractBilling ¶ added in v0.11.3
type ContractBilling types.ContractBilling
type DBContract ¶
type DBContract struct {
ContractID uint
TwinID uint
State string
CreatedAt uint
Name string
NodeID uint
DeploymentData string
DeploymentHash string
NumberOfPublicIps uint
Type string
FarmName string
FarmId uint64
}
DBContract is contract info
type Database ¶
type Database interface {
GetConnectionString() string
Ping() error
Initialized() error
GetRandomHealthyTwinIds(length int) ([]uint32, error)
GetLastUpsertsTimestamp() (types.IndexersState, error)
// server getters
GetStats(ctx context.Context, filter types.StatsFilter) (types.Stats, error)
GetNode(ctx context.Context, nodeID uint32) (Node, error)
GetFarm(ctx context.Context, farmID uint32) (Farm, error)
GetNodes(ctx context.Context, filter types.NodeFilter, limit types.Limit) ([]Node, uint, error)
GetFarms(ctx context.Context, filter types.FarmFilter, limit types.Limit) ([]Farm, uint, error)
GetTwins(ctx context.Context, filter types.TwinFilter, limit types.Limit) ([]types.Twin, uint, error)
GetContracts(ctx context.Context, filter types.ContractFilter, limit types.Limit) ([]DBContract, uint, error)
GetContract(ctx context.Context, contractID uint32) (DBContract, error)
GetContractBills(ctx context.Context, contractID uint32, limit types.Limit) ([]ContractBilling, uint, error)
GetContractsLatestBillReports(ctx context.Context, contractsIds []uint32, limit uint) ([]ContractBilling, error)
GetContractsTotalBilledAmount(ctx context.Context, contractIds []uint32) (uint64, error)
GetPublicIps(ctx context.Context, filter types.PublicIpFilter, limit types.Limit) ([]types.PublicIP, uint, error)
// indexer utils
DeleteOldGpus(ctx context.Context, nodeTwinIds []uint32, expiration int64) error
GetLastNodeTwinID(ctx context.Context) (uint32, error)
GetNodeTwinIDsAfter(ctx context.Context, twinID uint32) ([]uint32, error)
GetHealthyNodeTwinIds(ctx context.Context) ([]uint32, error)
// indexer upserters
UpsertNodesGPU(ctx context.Context, gpus []types.NodeGPU) error
UpsertNodeHealth(ctx context.Context, healthReports []types.HealthReport) error
UpsertNodeDmi(ctx context.Context, dmis []types.Dmi) error
UpsertNetworkSpeed(ctx context.Context, speeds []types.Speed) error
UpsertCpuBenchmark(ctx context.Context, cpuBenchmarks []types.CpuBenchmark) error
UpsertNodeIpv6Report(ctx context.Context, ips []types.HasIpv6) error
UpsertNodeWorkloads(ctx context.Context, workloads []types.NodesWorkloads) error
UpsertNodeFeatures(ctx context.Context, features []types.NodeFeatures) error
UpsertNodeLocation(ctx context.Context, locations []types.NodeLocation) error
}
Database interface for storing and fetching grid info
type Farm ¶
type Farm struct {
Name string
FarmID int
TwinID int
PricingPolicyID int
Certification string
StellarAddress string
Dedicated bool
PublicIps string
}
Farm data about a farm which is calculated from the chain
type Node ¶
type Node struct {
ID string
NodeID int64
FarmID int64
FarmName string
TwinID int64
Country string
GridVersion int64
City string
Continent string
Uptime int64
Created int64
FarmingPolicyID int64
UpdatedAt int64
TotalCru int64
TotalMru int64
TotalSru int64
TotalHru int64
UsedCru int64
UsedMru int64
UsedSru int64
UsedHru int64
Domain string
Gw4 string
Gw6 string
Ipv4 string
Ipv6 string
Certification string
FarmDedicated bool `gorm:"farm_dedicated"`
RentContractID int64
Renter int64
Rented bool
Rentable bool
SerialNumber string
Longitude *float64
Latitude *float64
Power NodePower `gorm:"type:jsonb;serializer:json"`
NumGPU int `gorm:"num_gpu"`
ExtraFee uint64
NodeContractsCount uint64 `gorm:"node_contracts_count"`
Healthy bool
Bios types.BIOS `gorm:"type:jsonb;serializer:json"`
Baseboard types.Baseboard `gorm:"type:jsonb;serializer:json"`
Memory []types.Memory `gorm:"type:jsonb;serializer:json"`
Processor []types.Processor `gorm:"type:jsonb;serializer:json"`
Gpus []types.NodeGPU `gorm:"type:jsonb;serializer:json"`
UploadSpeed float64 `gorm:"column:upload_speed"`
DownloadSpeed float64 `gorm:"column:download_speed"`
UDPDownloadIPv4 float64 `gorm:"column:udp_download_ipv4"`
UDPUploadIPv4 float64 `gorm:"column:udp_upload_ipv4"`
TCPDownloadIPv6 float64 `gorm:"column:tcp_download_ipv6"`
TCPUploadIPv6 float64 `gorm:"column:tcp_upload_ipv6"`
UDPDownloadIPv6 float64 `gorm:"column:udp_download_ipv6"`
UDPUploadIPv6 float64 `gorm:"column:udp_upload_ipv6"`
SingleThreaded float64
MultiThreaded float64
Threads int
Workloads int
PriceUsd float64
FarmFreeIps uint
Features []string `gorm:"type:jsonb;serializer:json"`
}
Node data about a node which is calculated from the chain
type NodesDistribution ¶
NodesDistribution is the number of nodes per each country
type PostgresDatabase ¶
type PostgresDatabase struct {
// contains filtered or unexported fields
}
PostgresDatabase postgres db client
func NewPostgresDatabase ¶
func NewPostgresDatabase(host string, port int, user, password, dbname string, maxConns int, logLevel logger.LogLevel) (PostgresDatabase, error)
NewPostgresDatabase returns a new postgres db client
func (*PostgresDatabase) DeleteOldGpus ¶ added in v0.14.2
func (*PostgresDatabase) GetConnectionString ¶ added in v0.11.3
func (d *PostgresDatabase) GetConnectionString() string
func (*PostgresDatabase) GetContract ¶ added in v0.11.3
func (d *PostgresDatabase) GetContract(ctx context.Context, contractID uint32) (DBContract, error)
GetContract return a single contract info
func (*PostgresDatabase) GetContractBills ¶ added in v0.11.3
func (d *PostgresDatabase) GetContractBills(ctx context.Context, contractID uint32, limit types.Limit) ([]ContractBilling, uint, error)
GetContract return a single contract all billing reports
func (*PostgresDatabase) GetContracts ¶
func (d *PostgresDatabase) GetContracts(ctx context.Context, filter types.ContractFilter, limit types.Limit) ([]DBContract, uint, error)
GetContracts returns contracts filtered and paginated
func (*PostgresDatabase) GetContractsLatestBillReports ¶ added in v0.15.6
func (d *PostgresDatabase) GetContractsLatestBillReports(ctx context.Context, contractsIds []uint32, limit uint) ([]ContractBilling, error)
GetContractsLatestBillReports return latest reports for some contracts
func (*PostgresDatabase) GetContractsTotalBilledAmount ¶ added in v0.15.6
func (d *PostgresDatabase) GetContractsTotalBilledAmount(ctx context.Context, contractIds []uint32) (uint64, error)
GetContractsTotalBilledAmount return a sum of all billed amount
func (*PostgresDatabase) GetFarms ¶
func (d *PostgresDatabase) GetFarms(ctx context.Context, filter types.FarmFilter, limit types.Limit) ([]Farm, uint, error)
GetFarms return farms filtered and paginated
func (*PostgresDatabase) GetHealthyNodeTwinIds ¶ added in v0.13.7
func (p *PostgresDatabase) GetHealthyNodeTwinIds(ctx context.Context) ([]uint32, error)
func (*PostgresDatabase) GetLastNodeTwinID ¶ added in v0.11.8
func (p *PostgresDatabase) GetLastNodeTwinID(ctx context.Context) (uint32, error)
func (*PostgresDatabase) GetLastUpsertsTimestamp ¶ added in v0.15.8
func (d *PostgresDatabase) GetLastUpsertsTimestamp() (types.IndexersState, error)
func (*PostgresDatabase) GetNodeTwinIDsAfter ¶ added in v0.11.8
func (*PostgresDatabase) GetNodes ¶
func (d *PostgresDatabase) GetNodes(ctx context.Context, filter types.NodeFilter, limit types.Limit) ([]Node, uint, error)
GetNodes returns nodes filtered and paginated
func (*PostgresDatabase) GetPublicIps ¶ added in v0.15.17
func (d *PostgresDatabase) GetPublicIps(ctx context.Context, filter types.PublicIpFilter, limit types.Limit) ([]types.PublicIP, uint, error)
GetPublicIps return all ips based on filters and pagination
func (*PostgresDatabase) GetRandomHealthyTwinIds ¶ added in v0.15.8
func (d *PostgresDatabase) GetRandomHealthyTwinIds(length int) ([]uint32, error)
func (*PostgresDatabase) GetStats ¶ added in v0.11.5
func (d *PostgresDatabase) GetStats(ctx context.Context, filter types.StatsFilter) (types.Stats, error)
GetStats returns aggregate info about the grid
func (*PostgresDatabase) GetTwins ¶
func (d *PostgresDatabase) GetTwins(ctx context.Context, filter types.TwinFilter, limit types.Limit) ([]types.Twin, uint, error)
GetTwins returns twins filtered and paginated
func (*PostgresDatabase) Initialize ¶ added in v0.13.0
func (d *PostgresDatabase) Initialize() error
func (*PostgresDatabase) Initialized ¶ added in v0.15.8
func (d *PostgresDatabase) Initialized() error
func (*PostgresDatabase) Ping ¶ added in v0.15.8
func (d *PostgresDatabase) Ping() error
func (*PostgresDatabase) UpsertCpuBenchmark ¶ added in v0.16.10
func (p *PostgresDatabase) UpsertCpuBenchmark(ctx context.Context, cpuBenchmarks []types.CpuBenchmark) error
func (*PostgresDatabase) UpsertNetworkSpeed ¶ added in v0.15.0
func (*PostgresDatabase) UpsertNodeDmi ¶ added in v0.15.0
func (*PostgresDatabase) UpsertNodeFeatures ¶ added in v0.15.18
func (p *PostgresDatabase) UpsertNodeFeatures(ctx context.Context, features []types.NodeFeatures) error
func (*PostgresDatabase) UpsertNodeHealth ¶ added in v0.13.5
func (p *PostgresDatabase) UpsertNodeHealth(ctx context.Context, healthReports []types.HealthReport) error
func (*PostgresDatabase) UpsertNodeIpv6Report ¶ added in v0.15.1
func (*PostgresDatabase) UpsertNodeLocation ¶ added in v0.16.5
func (p *PostgresDatabase) UpsertNodeLocation(ctx context.Context, locations []types.NodeLocation) error
func (*PostgresDatabase) UpsertNodeWorkloads ¶ added in v0.15.3
func (p *PostgresDatabase) UpsertNodeWorkloads(ctx context.Context, workloads []types.NodesWorkloads) error