Documentation
¶
Index ¶
- Constants
- func RegisterApiFlags(f []cli.Flag) []cli.Flag
- func RegisterFlags(f []cli.Flag) []cli.Flag
- type Api
- func (s *Api) DeleteResource(ctx context.Context, resourceID string) (*Resource, error)
- func (s *Api) GetResource(ctx context.Context, resourceID string) (*Resource, error)
- func (s *Api) GetResourceCached(ctx context.Context, resourceID string) (*Resource, error)
- func (s *Api) PutResource(ctx context.Context, resourceID string) (*Resource, error)
- type ErrorResponse
- type Resource
- type UserStats
- type Vault
- func (s *Vault) CreatePledge(ctx context.Context, user *auth.User, resource *vaultModels.Resource) (*vaultModels.Pledge, error)
- func (s *Vault) GetExpirePeriod() time.Duration
- func (s *Vault) GetFreezePeriod() time.Duration
- func (s *Vault) GetOrCreateResource(ctx context.Context, claims *api.Claims, resourceID string) (*vaultModels.Resource, error)
- func (s *Vault) GetPledge(ctx context.Context, user *auth.User, resource *vaultModels.Resource) (*vaultModels.Pledge, error)
- func (s *Vault) GetRequiredVP(ctx context.Context, claims *api.Claims, resourceID string) (float64, error)
- func (s *Vault) GetResource(ctx context.Context, resourceID string) (*vaultModels.Resource, error)
- func (s *Vault) GetTransferTimeoutPeriod() time.Duration
- func (s *Vault) GetUserStats(ctx context.Context, user *auth.User) (*UserStats, error)
- func (s *Vault) GetVaultAPIResource(ctx context.Context, resourceID string) (*Resource, error)
- func (s *Vault) IsPledgeFrozen(ctx context.Context, pledge *vaultModels.Pledge) (bool, error)
- func (s *Vault) RemovePledge(ctx context.Context, pledge *vaultModels.Pledge) error
- func (s *Vault) RemoveResource(ctx context.Context, resourceID string) error
- func (s *Vault) UpdateUserVP(ctx context.Context, user *auth.User) (*vaultModels.UserVP, error)
- func (s *Vault) UpdateUserVPIfExists(ctx context.Context, user *auth.User) (*vaultModels.UserVP, error)
Constants ¶
const ( StatusQueued = 0 StatusProcessing = 1 StatusCompleted = 2 StatusFailed = 3 )
Status constants for Resource
const ( VaultPledgeFreezePeriodFlag = "vault-pledge-freeze-period" VaultResourceExpirePeriodFlag = "vault-resource-expire-period" VaultResourceTransferTimeoutPeriodFlag = "vault-resource-transfer-timeout-period" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Api ¶
type Api struct {
// contains filtered or unexported fields
}
Api provides methods to interact with the Vault API
func (*Api) DeleteResource ¶
DeleteResource queues a resource for deletion from the Vault
func (*Api) GetResource ¶
GetResource retrieves a resource by ID from the Vault
func (*Api) GetResourceCached ¶
GetResourceCached retrieves a resource by ID with caching
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse represents an error response from the Vault API
type Resource ¶
type Resource struct {
ResourceID string `json:"resource_id"`
Status int `json:"status"`
StoredSize int64 `json:"stored_size"`
TotalSize int64 `json:"total_size"`
Error string `json:"error"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Resource represents a resource in the Vault
func (*Resource) GetProgress ¶
GetProgress returns the storage progress as a percentage (0-100)
type UserStats ¶
type UserStats struct {
Total *float64 // Total vault points (nil if unlimited)
Frozen float64 // Points in frozen and funded pledges
Funded float64 // Points in funded pledges
Available *float64 // Total minus funded (nil if total is nil)
Claimable float64 // Funded but not frozen
}
UserStats represents user vault points statistics
type Vault ¶
type Vault struct {
// contains filtered or unexported fields
}
func (*Vault) CreatePledge ¶
func (s *Vault) CreatePledge(ctx context.Context, user *auth.User, resource *vaultModels.Resource) (*vaultModels.Pledge, error)
CreatePledge creates a new pledge for a resource
func (*Vault) GetExpirePeriod ¶
GetExpirePeriod returns the resource expire period
func (*Vault) GetFreezePeriod ¶
GetFreezePeriod returns the pledge freeze period
func (*Vault) GetOrCreateResource ¶
func (s *Vault) GetOrCreateResource(ctx context.Context, claims *api.Claims, resourceID string) (*vaultModels.Resource, error)
GetOrCreateResource retrieves an existing resource or creates a new one if it doesn't exist
func (*Vault) GetPledge ¶
func (s *Vault) GetPledge(ctx context.Context, user *auth.User, resource *vaultModels.Resource) (*vaultModels.Pledge, error)
GetPledge retrieves a pledge for a specific user and resource, returns nil if not found
func (*Vault) GetRequiredVP ¶
func (s *Vault) GetRequiredVP(ctx context.Context, claims *api.Claims, resourceID string) (float64, error)
GetRequiredVP calculates the required vault points for a resource based on its total size
func (*Vault) GetResource ¶
GetResource retrieves a resource by ID, returns nil if not found
func (*Vault) GetTransferTimeoutPeriod ¶
GetTransferTimeoutPeriod returns the resource transfer timeout period
func (*Vault) GetUserStats ¶
GetUserStats returns vault points statistics for a user
func (*Vault) GetVaultAPIResource ¶
GetVaultAPIResource retrieves the vault API transfer status for a resource (non-cached, for real-time polling)
func (*Vault) IsPledgeFrozen ¶
IsPledgeFrozen checks if a pledge is currently in the freeze period A pledge is not frozen if the resource is vaulted, regardless of the freeze period
func (*Vault) RemovePledge ¶
RemovePledge removes a pledge and updates the resource accordingly
func (*Vault) RemoveResource ¶
RemoveResource removes a resource from the database and vault API
func (*Vault) UpdateUserVP ¶
UpdateUserVP updates user vault points based on claims
func (*Vault) UpdateUserVPIfExists ¶
func (s *Vault) UpdateUserVPIfExists(ctx context.Context, user *auth.User) (*vaultModels.UserVP, error)
UpdateUserVPIfExists updates user vault points only if user already has a record in Vault