commonsdk

package
v0.0.0-...-5a28939 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Main functionality of the SDK.

Index

Constants

View Source
const (
	OpUpload   int = 0
	OpDownload int = 1
	OpRepair   int = 2
	OpUpdate   int = 3
)
View Source
const (
	StorageV2 = 1
	KB        = 1024
	MB        = 1024 * KB
	GB        = 1024 * MB
)
View Source
const MINERSC_SCADDRESS = "6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d9"
View Source
const STORAGE_SCADDRESS = "6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d7"
View Source
const ZCNSC_SCADDRESS = "6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712e0"

Variables

This section is empty.

Functions

func AddFreeStorageAssigner

func AddFreeStorageAssigner(name, publicKey string, individualLimit, totalLimit float64) (string, int64, error)

AddFreeStorageAssigner adds a new free storage assigner (txn: `storagesc.add_free_allocation_assigner`). The free storage assigner is used to create free allocations. Can only be called by chain owner.

  • name is the name of the assigner.
  • publicKey is the public key of the assigner.
  • individualLimit is the individual limit of the assigner for a single free allocation request
  • totalLimit is the total limit of the assigner for all free allocation requests.

returns the hash of the transaction, the nonce of the transaction and an error if any.

func CancelAllocation

func CancelAllocation(allocID string) (hash string, nonce int64, err error)

CancelAllocation sends a cancel request for an allocation (txn: `storagesc.cancel_allocation`)

  • allocID is the id of the allocation.

returns the hash of the transaction, the nonce of the transaction and an error if any.

func CollectRewards

func CollectRewards(providerId string, providerType ProviderType) (string, int64, error)

CollectRewards collects the rewards for a provider (txn: `storagesc.collect_reward`)

  • providerId is the id of the provider.
  • providerType is the type of the provider.

func CommitToFabric

func CommitToFabric(metaTxnData, fabricConfigJSON string) (string, error)

func CreateAllocationForOwner

func CreateAllocationForOwner(
	owner, ownerpublickey string,
	datashards, parityshards int, size int64,
	readPrice, writePrice PriceRange,
	lock uint64, preferredBlobberIds, blobberAuthTickets []string, thirdPartyExtendable, IsEnterprise, force bool, fileOptionsParams *FileOptionsParameters, authRoundExpiry int64,
) (hash string, nonce int64, txn *transaction.Transaction, err error)

CreateAllocationForOwner creates a new allocation with the given options (txn: `storagesc.new_allocation_request`).

  • owner is the client id of the owner of the allocation.
  • ownerpublickey is the public key of the owner of the allocation.
  • datashards is the number of data shards for the allocation.
  • parityshards is the number of parity shards for the allocation.
  • size is the size of the allocation.
  • readPrice is the read price range for the allocation (Reads in Züs are free!).
  • writePrice is the write price range for the allocation.
  • lock is the lock value for the transaction (how much tokens to lock to the allocation, in SAS).
  • preferredBlobberIds is a list of preferred blobber ids for the allocation.
  • thirdPartyExtendable is a flag indicating whether the allocation can be extended by a third party.
  • fileOptionsParams is the file options parameters for the allocation, which control the usage permissions of the files in the allocation.

returns the hash of the transaction, the nonce of the transaction, the transaction object and an error if any.

func CreateAllocationWith

func CreateAllocationWith(options CreateAllocationOptions) (
	string, int64, *transaction.Transaction, error)

CreateAllocationWith creates a new allocation with the given options for the current client using the SDK. Similar ro CreateAllocationForOwner but uses an options struct instead of individual parameters.

  • options is the options struct instance for creating the allocation.

returns the hash of the new_allocation_request transaction, the nonce of the transaction, the transaction object and an error if any.

func CreateFreeAllocation

func CreateFreeAllocation(marker string, value uint64) (string, int64, error)

CreateFreeAllocation creates a new free allocation (txn: `storagesc.free_allocation_request`).

  • marker is the marker for the free allocation.
  • value is the value of the free allocation.

returns the hash of the transaction, the nonce of the transaction and an error if any.

func FinalizeAllocation

func FinalizeAllocation(allocID string) (hash string, nonce int64, err error)

FinalizeAllocation sends a finalize request for an allocation (txn: `storagesc.finalize_allocation`)

  • allocID is the id of the allocation.

returns the hash of the transaction, the nonce of the transaction and an error if any.

func GenerateOwnerSigningKey

func GenerateOwnerSigningKey(ownerPublicKey, ownerID string) (ed25519.PrivateKey, error)

func GetAllocationBlobbers

func GetAllocationBlobbers(
	storageVersion, datashards, parityshards int,
	size int64,
	isRestricted int,
	readPrice, writePrice PriceRange,
	force ...bool,
) ([]string, error)

GetAllocationBlobbers returns a list of blobber ids that can be used for a new allocation.

  • datashards is the number of data shards for the allocation.
  • parityshards is the number of parity shards for the allocation.
  • size is the size of the allocation.
  • readPrice is the read price range for the allocation (Reads in Züs are free!).
  • writePrice is the write price range for the allocation.
  • force is a flag indicating whether to force the allocation to be created.

returns the list of blobber ids and an error if any.

func GetAllocationMinLock

func GetAllocationMinLock(
	datashards, parityshards int,
	size int64,
	writePrice PriceRange,
) (int64, error)

GetAllocationMinLock calculates and returns the minimum lock demand for creating a new allocation, which represents the cost of the creation process.

  • datashards is the number of data shards for the allocation.
  • parityshards is the number of parity shards for the allocation.
  • size is the size of the allocation.
  • writePrice is the write price range for the allocation.

returns the minimum lock demand for the creation process and an error if any.

func GetBlobberIds

func GetBlobberIds(blobberUrls []string) ([]string, error)

GetBlobberIds returns a list of blobber ids that can be used for a new allocation.

  • blobberUrls is a list of blobber urls.

returns a list of blobber ids that can be used for the new allocation and an error if any.

func GetClientEncryptedPublicKey

func GetClientEncryptedPublicKey() (string, error)

GetClientEncryptedPublicKey - get the client's public key

func GetFreeAllocationBlobbers

func GetFreeAllocationBlobbers(request map[string]interface{}) ([]string, error)

GetFreeAllocationBlobbers returns a list of blobber ids that can be used for a new free allocation.

  • request is the request data for the free allocation.

returns a list of blobber ids that can be used for the new free allocation and an error if any.

func GetLogger

func GetLogger() *logger.Logger

GetLogger retrieves logger instance

func GetMptData

func GetMptData(key string) ([]byte, error)

GetMptData retrieves mpt key data.

func GetUpdateAllocTicket

func GetUpdateAllocTicket(allocationID, userID, operationType string, roundExpiry int64) (string, error)

func GetUpdateAllocationMinLock

func GetUpdateAllocationMinLock(
	allocationID string,
	size int64,
	extend bool,
	addBlobberId,
	removeBlobberId string) (int64, error)

GetUpdateAllocationMinLock returns the minimum lock demand for updating an allocation, which represents the cost of the update operation.

  • allocationID is the id of the allocation.
  • size is the new size of the allocation.
  • extend is a flag indicating whether to extend the expiry of the allocation.
  • addBlobberId is the id of the blobber to add to the allocation.
  • removeBlobberId is the id of the blobber to remove from the allocation.

returns the minimum lock demand for the update operation and an error if any.

func GetVersion

func GetVersion() string

GetVersion - returns version string

func InsertKilledProviderID

func InsertKilledProviderID(snId *StorageNodeIdField) (string, int64, error)

func KillProvider

func KillProvider(providerId string, providerType ProviderType) (string, int64, error)

KillProvider kills a blobber or a validator (txn: `storagesc.kill_blobber` or `storagesc.kill_validator`)

  • providerId is the id of the provider.
  • providerType` is the type of the provider, either 3 for `ProviderBlobber` or 4 for `ProviderValidator.

func ResetAllocationStats

func ResetAllocationStats(allocationId string) (string, int64, error)

func ResetBlobberStats

func ResetBlobberStats(rbs *ResetBlobberStatsDto) (string, int64, error)

ResetBlobberStats resets the stats of a blobber (txn: `storagesc.reset_blobber_stats`)

  • rbs is the reset blobber stats dto, contains the blobber id and its stats.

func ResetBlobberVersion

func ResetBlobberVersion(snId *StorageNodeIdField) (string, int64, error)

func SetLogFile

func SetLogFile(logFile string, verbose bool)

SetLogFile set the log file and verbosity levels

  • logFile: Log file
  • verbose: true - console output; false - no console output

func SetLogLevel

func SetLogLevel(lvl int)

SetLogLevel set the log level.

  • lvl: 0 disabled; higher number (upto 4) more verbosity

func SetShouldVerifyHash

func SetShouldVerifyHash(verify bool)

func SetSingleClietnMode

func SetSingleClietnMode(mode bool)

func ShutdownProvider

func ShutdownProvider(providerType ProviderType, providerID string) (string, int64, error)

ShutdownProvider shuts down a blobber or a validator (txn: `storagesc.shutdown_blobber` or `storagesc.shutdown_validator`)

  • providerId is the id of the provider.
  • providerType` is the type of the provider, either 3 for `ProviderBlobber` or 4 for `ProviderValidator.

func StakePoolLock

func StakePoolLock(providerType ProviderType, providerID string, value, fee uint64) (hash string, nonce int64, err error)

StakePoolLock locks tokens in a stake pool. This function is the entry point for the staking operation. Provided the provider type and provider ID, the value is locked in the stake pool between the SDK client and the provider. Based on the locked amount, the client will get rewards as share of the provider's rewards.

  • providerType: provider type
  • providerID: provider ID
  • value: value to lock
  • fee: transaction fee

func StakePoolUnlock

func StakePoolUnlock(providerType ProviderType, providerID, clientID string, fee uint64) (unstake int64, nonce int64, err error)

StakePoolUnlock unlocks a stake pool tokens. If tokens can't be unlocked due to opened offers, then it returns time where the tokens can be unlocked, marking the pool as 'want to unlock' to avoid its usage in offers in the future. The time is maximal time that can be lesser in some cases. To unlock tokens can't be unlocked now, wait the time and unlock them (call this function again).

  • providerType: provider type
  • providerID: provider ID
  • fee: transaction fee

func StartWriteWorker

func StartWriteWorker(ctx context.Context, source io.Reader, dataChan chan *DataChan, chunkDataSizePerRead int64)

func StorageSmartContractTxn

func StorageSmartContractTxn(sn transaction.SmartContractTxnData) (
	hash, out string, nonce int64, txn *transaction.Transaction, err error)

func UpdateBlobberSettings

func UpdateBlobberSettings(blob *UpdateBlobber) (resp string, nonce int64, err error)

UpdateBlobberSettings updates the settings of a blobber (txn: `storagesc.update_blobber_settings`)

  • blob is the update blobber request inputs.

func UpdateValidatorSettings

func UpdateValidatorSettings(v *UpdateValidator) (resp string, nonce int64, err error)

UpdateValidatorSettings updates the settings of a validator (txn: `storagesc.update_validator_settings`)

  • v is the update validator request inputs.

func WritePoolLock

func WritePoolLock(allocID string, tokens, fee uint64) (hash string, nonce int64, err error)

WritePoolLock locks given number of tokes for given duration in read pool.

  • allocID: allocation ID
  • tokens: number of tokens to lock
  • fee: transaction fee

func WritePoolUnlock

func WritePoolUnlock(allocID string, fee uint64) (hash string, nonce int64, err error)

WritePoolUnlock unlocks ALL tokens of a write pool. Needs to be cancelled first.

  • allocID: allocation ID
  • fee: transaction fee

Types

type Allocation

type Allocation struct {
	// ID is the unique identifier of the allocation.
	ID string `json:"id"`
	// Tx is the transaction hash of the latest transaction related to the allocation.
	Tx string `json:"tx"`

	// DataShards is the number of data shards.
	DataShards int `json:"data_shards"`

	// ParityShards is the number of parity shards.
	ParityShards int `json:"parity_shards"`

	// Size is the size of the allocation.
	Size int64 `json:"size"`

	// Expiration is the expiration date of the allocation.
	Expiration int64 `json:"expiration_date"`

	// Owner is the id of the owner of the allocation.
	Owner string `json:"owner_id"`

	// OwnerPublicKey is the public key of the owner of the allocation.
	OwnerPublicKey string `json:"owner_public_key"`

	// Payer is the id of the payer of the allocation.
	Payer string `json:"payer_id"`

	// Blobbers is the list of blobbers that store the data of the allocation.
	Blobbers []*blockchain.StorageNode `json:"blobbers"`

	// Stats contains the statistics of the allocation.
	Stats *AllocationStats `json:"stats"`

	// TimeUnit is the time unit of the allocation.
	TimeUnit time.Duration `json:"time_unit"`

	// WritePool is the write pool of the allocation.
	WritePool common.Balance `json:"write_pool"`

	// BlobberDetails contains real terms used for the allocation.
	// If the allocation has updated, then terms calculated using
	// weighted average values.
	BlobberDetails []*BlobberAllocation `json:"blobber_details"`

	// ReadPriceRange is requested reading prices range.
	ReadPriceRange PriceRange `json:"read_price_range"`

	// WritePriceRange is requested writing prices range.
	WritePriceRange PriceRange `json:"write_price_range"`

	// MinLockDemand is the minimum lock demand of the allocation.
	MinLockDemand float64 `json:"min_lock_demand"`

	// ChallengeCompletionTime is the time taken to complete a challenge.
	ChallengeCompletionTime time.Duration `json:"challenge_completion_time"`

	// StartTime is the start time of the allocation.
	StartTime common.Timestamp `json:"start_time"`

	// Finalized is the flag to indicate if the allocation is finalized.
	Finalized bool `json:"finalized,omitempty"`

	// Cancelled is the flag to indicate if the allocation is cancelled.
	Canceled bool `json:"canceled,omitempty"`

	// MovedToChallenge is the amount moved to challenge pool related to the allocation.
	MovedToChallenge common.Balance `json:"moved_to_challenge,omitempty"`

	// MovedBack is the amount moved back from the challenge pool related to the allocation.
	MovedBack common.Balance `json:"moved_back,omitempty"`

	// MovedToValidators is the amount moved to validators related to the allocation.
	MovedToValidators common.Balance `json:"moved_to_validators,omitempty"`

	// FileOptions is a bitmask of file options, which are the permissions of the allocation.
	FileOptions uint16 `json:"file_options"`

	IsEnterprise bool `json:"is_enterprise"`

	StorageVersion int `json:"storage_version"`

	// Owner ecdsa public key
	OwnerSigningPublicKey string `json:"owner_signing_public_key"`

	// FileOptions to define file restrictions on an allocation for third-parties
	// default 00000000 for all crud operations suggesting only owner has the below listed abilities.
	// enabling option/s allows any third party to perform certain ops
	// 		00000001 - 1  - upload
	// 		00000010 - 2  - delete
	// 		00000100 - 4  - update
	// 		00001000 - 8  - move
	// 		00010000 - 16 - copy
	// 		00100000 - 32 - rename
	ThirdPartyExtendable bool `json:"third_party_extendable"`
}

type AllocationStats

type AllocationStats struct {
	UsedSize                  int64  `json:"used_size"`
	NumWrites                 int64  `json:"num_of_writes"`
	NumReads                  int64  `json:"num_of_reads"`
	TotalChallenges           int64  `json:"total_challenges"`
	OpenChallenges            int64  `json:"num_open_challenges"`
	SuccessChallenges         int64  `json:"num_success_challenges"`
	FailedChallenges          int64  `json:"num_failed_challenges"`
	LastestClosedChallengeTxn string `json:"latest_closed_challenge"`
}

type BackPool

type BackPool struct {
	ID      string         `json:"id"`
	Balance common.Balance `json:"balance"`
}

type Blobber

type Blobber struct {
	// ID of the blobber
	ID common.Key `json:"id"`

	// BaseURL of the blobber
	BaseURL string `json:"url"`

	// Terms of the blobber
	Terms Terms `json:"terms"`

	// Capacity of the blobber
	Capacity common.Size `json:"capacity"`

	// Allocated size of the blobber
	Allocated common.Size `json:"allocated"`

	// LastHealthCheck of the blobber
	LastHealthCheck common.Timestamp `json:"last_health_check"`

	// PublicKey of the blobber
	PublicKey string `json:"-"`

	// StakePoolSettings settings of the blobber staking
	StakePoolSettings blockchain.StakePoolSettings `json:"stake_pool_settings"`

	// TotalStake of the blobber in SAS
	TotalStake int64 `json:"total_stake"`

	// UsedAllocation of the blobber in SAS
	UsedAllocation int64 `json:"used_allocation"`

	// TotalOffers of the blobber in SAS
	TotalOffers int64 `json:"total_offers"`

	// TotalServiceCharge of the blobber in SAS
	TotalServiceCharge int64 `json:"total_service_charge"`

	// UncollectedServiceCharge of the blobber in SAS
	UncollectedServiceCharge int64 `json:"uncollected_service_charge"`

	// IsKilled flag of the blobber, if true then the blobber is killed
	IsKilled bool `json:"is_killed"`

	// IsShutdown flag of the blobber, if true then the blobber is shutdown
	IsShutdown bool `json:"is_shutdown"`

	// NotAvailable flag of the blobber, if true then the blobber is not available
	NotAvailable bool `json:"not_available"`

	// IsRestricted flag of the blobber, if true then the blobber is restricted
	IsRestricted bool `json:"is_restricted"`
}

Blobber type represents blobber information.

func GetBlobber

func GetBlobber(blobberID string) (blob *Blobber, err error)

GetBlobber retrieve blobber by id.

  • blobberID: the id of blobber

func GetBlobbers

func GetBlobbers(active, stakable bool) (bs []*Blobber, err error)

GetBlobbers returns list of blobbers.

  • active: if true then only active blobbers are returned
  • stakable: if true then only stakable blobbers are returned

type BlobberAllocation

type BlobberAllocation struct {
	BlobberID       string         `json:"blobber_id"`
	Size            int64          `json:"size"`
	Terms           Terms          `json:"terms"`
	MinLockDemand   common.Balance `json:"min_lock_demand"`
	Spent           common.Balance `json:"spent"`
	Penalty         common.Balance `json:"penalty"`
	ReadReward      common.Balance `json:"read_reward"`
	Returned        common.Balance `json:"returned"`
	ChallengeReward common.Balance `json:"challenge_reward"`
	FinalReward     common.Balance `json:"final_reward"`
}

BlobberAllocation represents the blobber in the context of an allocation

type ChallengePoolInfo

type ChallengePoolInfo struct {
	ID         string           `json:"id"`
	Balance    common.Balance   `json:"balance"`
	StartTime  common.Timestamp `json:"start_time"`
	Expiration common.Timestamp `json:"expiration"`
	Finalized  bool             `json:"finalized"`
}

ChallengePoolInfo represents a challenge pool stat.

func GetChallengePoolInfo

func GetChallengePoolInfo(allocID string) (info *ChallengePoolInfo, err error)

GetChallengePoolInfo retrieve challenge pool info for given allocation.

  • allocID: allocation ID

type CreateAllocationOptions

type CreateAllocationOptions struct {
	DataShards           int
	ParityShards         int
	Size                 int64
	ReadPrice            PriceRange
	WritePrice           PriceRange
	Lock                 uint64
	BlobberIds           []string
	BlobberAuthTickets   []string
	ThirdPartyExtendable bool
	IsEnterprise         bool
	FileOptionsParams    *FileOptionsParameters
	Force                bool
	StorageVersion       int
	AuthRoundExpiry      int64
}

CreateAllocationOptions is used to specify the options for creating a new allocation.

type DataChan

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

Example implementation of a reader

type DownloadRequestHeader

type DownloadRequestHeader struct {
	ClientID       string
	PathHash       string
	BlockNum       int64
	NumBlocks      int64
	ReadMarker     []byte
	AuthToken      []byte
	DownloadMode   string
	VerifyDownload bool
	ConnectionID   string
	Version        string
}

DownloadRequestHeader download request header

func (*DownloadRequestHeader) ToFastHeader

func (h *DownloadRequestHeader) ToFastHeader(req *fasthttp.Request)

func (*DownloadRequestHeader) ToHeader

func (h *DownloadRequestHeader) ToHeader(req *http.Request)

ToHeader update header

type FileOptionParam

type FileOptionParam struct {
	Changed bool
	Value   bool
}

type FileOptionsParameters

type FileOptionsParameters struct {
	ForbidUpload FileOptionParam
	ForbidDelete FileOptionParam
	ForbidUpdate FileOptionParam
	ForbidMove   FileOptionParam
	ForbidCopy   FileOptionParam
	ForbidRename FileOptionParam
}

FileOptionsParameters is used to specify the file options parameters for an allocation, which control the usage permissions of the files in the allocation.

type M3u8Writer

type M3u8Writer interface {
	io.WriteSeeker
	Truncate(size int64) error
	Sync() error
}

M3u8Writer m3u8 writer

type MediaPlaylist

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

MediaPlaylist queue-based m3u8 playlist

func NewMediaPlaylist

func NewMediaPlaylist(delay int, dir string, writer M3u8Writer) *MediaPlaylist

NewMediaPlaylist create media playlist(.m3u8)

func (*MediaPlaylist) Append

func (m *MediaPlaylist) Append(item string)

Append append new item into playlist

func (*MediaPlaylist) Encode

func (m *MediaPlaylist) Encode() []byte

Encode encode m3u8

func (*MediaPlaylist) Play

func (m *MediaPlaylist) Play()

Play start to play the contents of the playlist with 1 second buffer between each item

func (*MediaPlaylist) String

func (m *MediaPlaylist) String() string

String implement Stringer

type PriceRange

type PriceRange struct {
	Min uint64 `json:"min"`
	Max uint64 `json:"max"`
}

PriceRange represents a price range allowed by user to filter blobbers.

func (*PriceRange) IsValid

func (pr *PriceRange) IsValid() bool

IsValid price range.

type ProviderType

type ProviderType int

ProviderType is the type of the provider.

const (
	ProviderMiner ProviderType = iota + 1
	ProviderSharder
	ProviderBlobber
	ProviderValidator
	ProviderAuthorizer
)

type ResetBlobberStatsDto

type ResetBlobberStatsDto struct {
	BlobberID     string `json:"blobber_id"`
	PrevAllocated int64  `json:"prev_allocated"`
	PrevSavedData int64  `json:"prev_saved_data"`
	NewAllocated  int64  `json:"new_allocated"`
	NewSavedData  int64  `json:"new_saved_data"`
}

ResetBlobberStatsDto represents blobber stats reset request.

type StakePoolDelegatePoolInfo

type StakePoolDelegatePoolInfo struct {
	ID         common.Key     `json:"id"`          // blobber ID
	Balance    common.Balance `json:"balance"`     // current balance
	DelegateID common.Key     `json:"delegate_id"` // wallet
	Rewards    common.Balance `json:"rewards"`     // current
	UnStake    bool           `json:"unstake"`     // want to unstake

	TotalReward  common.Balance   `json:"total_reward"`
	TotalPenalty common.Balance   `json:"total_penalty"`
	Status       string           `json:"status"`
	RoundCreated int64            `json:"round_created"`
	StakedAt     common.Timestamp `json:"staked_at"`
}

StakePoolDelegatePoolInfo represents delegate pool of a stake pool info.

type StakePoolInfo

type StakePoolInfo struct {
	ID         common.Key     `json:"pool_id"` // pool ID
	Balance    common.Balance `json:"balance"` // total balance
	StakeTotal common.Balance `json:"stake_total"`
	// delegate pools
	Delegate []StakePoolDelegatePoolInfo `json:"delegate"`
	// rewards
	Rewards common.Balance `json:"rewards"`
	// total rewards
	TotalRewards common.Balance `json:"total_rewards"`
	// Settings of the stake pool
	Settings blockchain.StakePoolSettings `json:"settings"`
}

StakePool information of stake pool of a provider.

func GetStakePoolInfo

func GetStakePoolInfo(providerType ProviderType, providerID string) (info *StakePoolInfo, err error)

GetStakePoolInfo retrieve stake pool info for the current client configured to the sdk, given provider type and provider ID.

  • providerType: provider type
  • providerID: provider ID

type StakePoolOfferInfo

type StakePoolOfferInfo struct {
	Lock         common.Balance   `json:"lock"`
	Expire       common.Timestamp `json:"expire"`
	AllocationID common.Key       `json:"allocation_id"`
	IsExpired    bool             `json:"is_expired"`
}

StakePoolOfferInfo represents stake pool offer information.

type StakePoolRewardsInfo

type StakePoolRewardsInfo struct {
	Charge    common.Balance `json:"charge"`    // total for all time
	Blobber   common.Balance `json:"blobber"`   // total for all time
	Validator common.Balance `json:"validator"` // total for all time
}

StakePoolRewardsInfo represents stake pool rewards.

type StakePoolUserInfo

type StakePoolUserInfo struct {
	Pools map[common.Key][]*StakePoolDelegatePoolInfo `json:"pools"`
}

StakePoolUserInfo represents user stake pools statistic.

func GetStakePoolUserInfo

func GetStakePoolUserInfo(clientID string, offset, limit int) (info *StakePoolUserInfo, err error)

GetStakePoolUserInfo obtains blobbers/validators delegate pools statistic for a user. If given clientID is empty string, then current client used.

  • clientID: client ID
  • offset: offset
  • limit: limit

type StatusCallback

type StatusCallback interface {
	Started(allocationId, filePath string, op int, totalBytes int)
	InProgress(allocationId, filePath string, op int, completedBytes int, data []byte)
	Error(allocationID string, filePath string, op int, err error)
	Completed(allocationId, filePath string, filename string, mimetype string, size int, op int)
	RepairCompleted(filesRepaired int)
}

type StorageNodeIdField

type StorageNodeIdField struct {
	Id string `json:"id"`
}

type StreamReader

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

func NewStreamReader

func NewStreamReader(dataChan chan *DataChan) *StreamReader

func (*StreamReader) Read

func (r *StreamReader) Read(p []byte) (int, error)

Client should always send bytes equal to less than chunkDataSizePerRead

type Terms

type Terms struct {
	ReadPrice        common.Balance `json:"read_price"`  // tokens / GB
	WritePrice       common.Balance `json:"write_price"` // tokens / GB
	MaxOfferDuration time.Duration  `json:"max_offer_duration"`
}

Terms represents Blobber terms. A Blobber can update its terms, but any existing offer will use terms of offer signing time.

type UpdateBlobber

type UpdateBlobber struct {
	ID                       common.Key                          `json:"id"`
	BaseURL                  *string                             `json:"url,omitempty"`
	Terms                    *UpdateTerms                        `json:"terms,omitempty"`
	Capacity                 *common.Size                        `json:"capacity,omitempty"`
	Allocated                *common.Size                        `json:"allocated,omitempty"`
	LastHealthCheck          *common.Timestamp                   `json:"last_health_check,omitempty"`
	StakePoolSettings        *blockchain.UpdateStakePoolSettings `json:"stake_pool_settings,omitempty"`
	TotalStake               *int64                              `json:"total_stake,omitempty"`
	UsedAllocation           *int64                              `json:"used_allocation,omitempty"`
	TotalOffers              *int64                              `json:"total_offers,omitempty"`
	TotalServiceCharge       *int64                              `json:"total_service_charge,omitempty"`
	UncollectedServiceCharge *int64                              `json:"uncollected_service_charge,omitempty"`
	IsKilled                 *bool                               `json:"is_killed,omitempty"`
	IsShutdown               *bool                               `json:"is_shutdown,omitempty"`
	NotAvailable             *bool                               `json:"not_available,omitempty"`
	IsRestricted             *bool                               `json:"is_restricted,omitempty"`
	StorageVersion           *int                                `json:"storage_version,omitempty"`
	DelegateWallet           *string                             `json:"delegate_wallet,omitempty"`
}

UpdateBlobber is used during update blobber settings calls. Note the types are of pointer types with omitempty json property. This is done to correctly identify which properties are actually changing.

type UpdateTerms

type UpdateTerms struct {
	ReadPrice        *common.Balance `json:"read_price,omitempty"`  // tokens / GB
	WritePrice       *common.Balance `json:"write_price,omitempty"` // tokens / GB
	MaxOfferDuration *time.Duration  `json:"max_offer_duration,omitempty"`
}

UpdateTerms represents Blobber terms during update blobber calls. A Blobber can update its terms, but any existing offer will use terms of offer signing time.

type UpdateValidator

type UpdateValidator struct {
	ID                       common.Key        `json:"validator_id"`
	BaseURL                  *string           `json:"url,omitempty"`
	DelegateWallet           *string           `json:"delegate_wallet,omitempty"`
	MinStake                 *common.Balance   `json:"min_stake,omitempty"`
	MaxStake                 *common.Balance   `json:"max_stake,omitempty"`
	NumDelegates             *int              `json:"num_delegates,omitempty"`
	ServiceCharge            *float64          `json:"service_charge,omitempty"`
	StakeTotal               *int64            `json:"stake_total,omitempty"`
	TotalServiceCharge       *int64            `json:"total_service_charge,omitempty"`
	UncollectedServiceCharge *int64            `json:"uncollected_service_charge,omitempty"`
	LastHealthCheck          *common.Timestamp `json:"last_health_check,omitempty"`
	IsKilled                 *bool             `json:"is_killed,omitempty"`
	IsShutdown               *bool             `json:"is_shutdown,omitempty"`
}

UpdateValidator is used during update validator settings calls. Note the types are of pointer types with omitempty json property. This is done to correctly identify which properties are actually changing.

func (*UpdateValidator) ConvertToValidationNode

func (v *UpdateValidator) ConvertToValidationNode() *blockchain.UpdateValidationNode

ConvertToValidationNode converts UpdateValidator request to blockchain.UpdateValidationNode.

type UploadFileMeta

type UploadFileMeta struct {
	// Name remote file name
	Name string
	// Path remote path
	Path string
	// Hash hash of entire source file
	Hash     string
	MimeType string
	// Size total bytes of entire source file
	Size int64

	// ThumbnailSize total bytes of entire thumbnail
	ThumbnailSize int64
	// ThumbnailHash hash code of entire thumbnail
	ThumbnailHash string
}

type UploadResult

type UploadResult struct {
	Filename   string `json:"filename"`
	ShardSize  int64  `json:"size"`
	Hash       string `json:"content_hash,omitempty"`
	MerkleRoot string `json:"merkle_root,omitempty"`
}

type Validator

type Validator struct {
	ID                       common.Key       `json:"validator_id"`
	BaseURL                  string           `json:"url"`
	PublicKey                string           `json:"-"`
	DelegateWallet           string           `json:"delegate_wallet"`
	MinStake                 common.Balance   `json:"min_stake"`
	MaxStake                 common.Balance   `json:"max_stake"`
	NumDelegates             int              `json:"num_delegates"`
	ServiceCharge            float64          `json:"service_charge"`
	StakeTotal               int64            `json:"stake_total"`
	TotalServiceCharge       int64            `json:"total_service_charge"`
	UncollectedServiceCharge int64            `json:"uncollected_service_charge"`
	LastHealthCheck          common.Timestamp `json:"last_health_check"`
	IsKilled                 bool             `json:"is_killed"`
	IsShutdown               bool             `json:"is_shutdown"`
}

Validator represents validator information.

func GetValidator

func GetValidator(validatorID string) (validator *Validator, err error)

GetValidator retrieve validator instance by id.

  • validatorID: the id of validator

func GetValidators

func GetValidators(stakable bool) (validators []*Validator, err error)

GetValidators returns list of validators.

  • stakable: if true then only stakable validators are returned

Jump to

Keyboard shortcuts

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