Documentation
¶
Index ¶
- Constants
- func MigrateFromJSON(db *bolt.DB, jsonData []byte) error
- func OpenDB(path string) (*bolt.DB, error)
- type CachedProvider
- type MonikerCache
- type ProviderCache
- func (c *ProviderCache) GetAllProviders() map[string]*CachedProvider
- func (c *ProviderCache) GetOnlineProviders() []*CachedProvider
- func (c *ProviderCache) GetProvider(owner string) (*CachedProvider, bool)
- func (c *ProviderCache) GetProvidersByPriority() []string
- func (c *ProviderCache) GetProvidersDueForCheck() []string
- func (c *ProviderCache) HasProviders() bool
- func (c *ProviderCache) MarkProviderOffline(owner string)
- func (c *ProviderCache) MarkProviderOnline(owner, version string, ...)
- func (c *ProviderCache) OnlineCount() int
- func (c *ProviderCache) ProviderCount() int
- func (c *ProviderCache) Save() error
- func (c *ProviderCache) SyncWithChain(onChainProviders []rpc.OnChainProvider) []string
- type ProviderStore
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func MigrateFromJSON ¶
MigrateFromJSON imports aktop-format JSON provider cache into bbolt. This is a one-time migration helper. Pass nil to skip.
Types ¶
type CachedProvider ¶
type CachedProvider struct {
HostURI string `json:"host_uri"`
Name string `json:"name"`
Country string `json:"country"`
Attributes map[string]string `json:"attributes"`
IsOnline bool `json:"is_online"`
Version string `json:"version"`
CPUAvailable uint64 `json:"cpu_available"`
CPUTotal uint64 `json:"cpu_total"`
MemAvailable uint64 `json:"mem_available"`
MemTotal uint64 `json:"mem_total"`
GPUAvailable uint64 `json:"gpu_available"`
GPUTotal uint64 `json:"gpu_total"`
GPUModels []string `json:"gpu_models,omitempty"`
LastSeenOnline time.Time `json:"last_seen_online"`
LastChecked time.Time `json:"last_checked"`
ConsecutiveFailures int `json:"consecutive_failures"`
}
CachedProvider represents a provider with cached status information.
type MonikerCache ¶
type MonikerCache struct {
// contains filtered or unexported fields
}
MonikerCache stores validator pubkey -> moniker mappings in bbolt.
func OpenMonikerCache ¶
func OpenMonikerCache(db *bolt.DB) (*MonikerCache, error)
OpenMonikerCache opens or creates the moniker cache in the given bbolt database.
func (*MonikerCache) Get ¶
func (c *MonikerCache) Get() map[string]string
Get returns all monikers as a map.
func (*MonikerCache) HasMonikers ¶
func (c *MonikerCache) HasMonikers() bool
HasMonikers returns true if the cache has any entries.
func (*MonikerCache) Save ¶
func (c *MonikerCache) Save() error
Save is a no-op for bbolt — data is already persisted on each write.
func (*MonikerCache) Set ¶
func (c *MonikerCache) Set(monikers map[string]string)
Set replaces all monikers with the given map.
type ProviderCache ¶
type ProviderCache struct {
// contains filtered or unexported fields
}
ProviderCache manages provider data inside a bbolt database.
func Open ¶
func Open(db *bolt.DB) (*ProviderCache, error)
Open opens or creates the provider cache in the given bbolt database. It ensures the required buckets exist.
func (*ProviderCache) GetAllProviders ¶
func (c *ProviderCache) GetAllProviders() map[string]*CachedProvider
GetAllProviders returns all cached providers.
func (*ProviderCache) GetOnlineProviders ¶
func (c *ProviderCache) GetOnlineProviders() []*CachedProvider
GetOnlineProviders returns all providers that are currently online.
func (*ProviderCache) GetProvider ¶
func (c *ProviderCache) GetProvider(owner string) (*CachedProvider, bool)
GetProvider returns a provider by owner address.
func (*ProviderCache) GetProvidersByPriority ¶
func (c *ProviderCache) GetProvidersByPriority() []string
GetProvidersByPriority returns providers sorted by check priority: unchecked (0) > online (1) > recently offline (2) > long-term offline (3)
func (*ProviderCache) GetProvidersDueForCheck ¶
func (c *ProviderCache) GetProvidersDueForCheck() []string
GetProvidersDueForCheck returns providers that need to be checked based on smart scheduling.
func (*ProviderCache) HasProviders ¶
func (c *ProviderCache) HasProviders() bool
HasProviders returns true if the cache has any providers.
func (*ProviderCache) MarkProviderOffline ¶
func (c *ProviderCache) MarkProviderOffline(owner string)
MarkProviderOffline marks a provider as offline.
func (*ProviderCache) MarkProviderOnline ¶
func (c *ProviderCache) MarkProviderOnline(owner, version string, cpuAvail, cpuTotal, memAvail, memTotal, gpuAvail, gpuTotal uint64, gpuModels []string)
MarkProviderOnline marks a provider as online with updated stats.
func (*ProviderCache) OnlineCount ¶
func (c *ProviderCache) OnlineCount() int
OnlineCount returns the number of online providers.
func (*ProviderCache) ProviderCount ¶
func (c *ProviderCache) ProviderCount() int
ProviderCount returns the total number of providers in cache.
func (*ProviderCache) Save ¶
func (c *ProviderCache) Save() error
Save is a no-op for bbolt — data is already persisted on each write.
func (*ProviderCache) SyncWithChain ¶
func (c *ProviderCache) SyncWithChain(onChainProviders []rpc.OnChainProvider) []string
SyncWithChain syncs the cache with on-chain providers. Returns a list of new provider owners that weren't in the cache.
type ProviderStore ¶
type ProviderStore interface {
HasProviders() bool
GetProvider(owner string) (*CachedProvider, bool)
GetAllProviders() map[string]*CachedProvider
GetOnlineProviders() []*CachedProvider
MarkProviderOnline(owner, version string, cpuAvail, cpuTotal, memAvail, memTotal, gpuAvail, gpuTotal uint64, gpuModels []string)
MarkProviderOffline(owner string)
SyncWithChain(onChainProviders []rpc.OnChainProvider) []string
GetProvidersDueForCheck() []string
GetProvidersByPriority() []string
ProviderCount() int
OnlineCount() int
Save() error
}
ProviderStore defines the interface for provider caching operations.