Documentation
¶
Index ¶
- Variables
- type ContractBilling
- type DBContract
- type Database
- type Farm
- type Node
- type NodeGPU
- type NodePower
- type NodesDistribution
- type PostgresDatabase
- func (d *PostgresDatabase) Close() 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) 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) GetLastNodeTwinID(ctx context.Context) (int64, error)
- func (d *PostgresDatabase) GetNode(ctx context.Context, nodeID uint32) (Node, error)
- func (p *PostgresDatabase) GetNodeTwinIDsAfter(ctx context.Context, twinID int64) ([]int64, error)
- func (d *PostgresDatabase) GetNodes(ctx context.Context, filter types.NodeFilter, limit types.Limit) ([]Node, uint, 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 (p *PostgresDatabase) UpsertNodesGPU(ctx context.Context, nodesGPU []types.NodeGPU) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNodeNotFound node not found ErrNodeNotFound = errors.New("node not found") // ErrFarmNotFound farm not found ErrFarmNotFound = errors.New("farm not found") //ErrViewNotFound ErrNodeResourcesViewNotFound = errors.New("ERROR: relation \"nodes_resources_view\" 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
}
DBContract is contract info
type Database ¶
type Database interface {
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)
UpsertNodesGPU(ctx context.Context, nodesGPU []types.NodeGPU) error
GetLastNodeTwinID(ctx context.Context) (int64, error)
GetNodeTwinIDsAfter(ctx context.Context, twinID int64) ([]int64, error)
GetConnectionString() string
}
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
TwinID int64
Country string
GridVersion int64
City 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
RentedByTwinID int64
SerialNumber string
Longitude *float64
Latitude *float64
Power NodePower `gorm:"type:jsonb"`
NumGPU int `gorm:"num_gpu"`
ExtraFee uint64
HasNodeContract bool `gorm:"has_node_contract"`
}
Node data about a node which is calculated from the chain
type NodeGPU ¶
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 (*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 info
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) 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) GetLastNodeTwinID ¶ added in v0.11.8
func (p *PostgresDatabase) GetLastNodeTwinID(ctx context.Context) (int64, 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) 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) UpsertNodesGPU ¶
Click to show internal directories.
Click to hide internal directories.