Documentation ¶
Index ¶
- Constants
- Variables
- func ClientPayouts(host storage.HostInfo, funding common.BigInt, basePrice common.BigInt, ...) (clientPayout common.BigInt, hostPayout common.BigInt, ...)
- func PubkeyToEnodeID(pubkey *ecdsa.PublicKey) enode.ID
- func RentPaymentValidation(rent storage.RentPayment) (err error)
- type ContractManager
- func (cm *ContractManager) AcquireRentPayment() (rentPayment storage.RentPayment)
- func (cm *ContractManager) CalculatePeriodCost(rentPayment storage.RentPayment) (periodCost storage.PeriodCost)
- func (cm *ContractManager) ContractCreate(params storage.ContractParams) (md storage.ContractMetaData, err error)
- func (cm *ContractManager) ContractRenew(oldContract *contractset.Contract, params storage.ContractParams) (md storage.ContractMetaData, err error)
- func (cm *ContractManager) GetStorageContractSet() (contractSet *contractset.StorageContractSet)
- func (cm *ContractManager) HostHealthMap() (infoTable storage.HostHealthInfoTable)
- func (cm *ContractManager) HostHealthMapByID(hostIDs []enode.ID) (infoTable storage.HostHealthInfoTable)
- func (cm *ContractManager) InsertRandomActiveContracts(amount int) (err error)
- func (cm *ContractManager) RetrieveActiveContract(contractID storage.ContractID) (contract storage.ContractMetaData, exists bool)
- func (cm *ContractManager) RetrieveActiveContracts() (cms []storage.ContractMetaData)
- func (cm *ContractManager) RetrievePeriodCost() storage.PeriodCost
- func (cm *ContractManager) RetrieveRateLimit() (readBPS, writeBPS int64, packetSize uint64)
- func (cm *ContractManager) SetRateLimits(readBPS int64, writeBPS int64, packetSize uint64)
- func (cm *ContractManager) SetRentPayment(rent storage.RentPayment, market hostMarket) (err error)
- func (cm *ContractManager) Start(b storage.ClientBackend) (err error)
- func (cm *ContractManager) Stop()
Constants ¶
const ( PersistContractManagerHeader = "Storage Contract Manager Settings" PersistContractManagerVersion = "1.0" PersistFileName = "storagecontractmanager.json" )
persistent related constants
Variables ¶
var (
ErrHostFault = errors.New("host has returned an error")
)
ErrHostFault indicates if the error is caused by the storage host
Functions ¶
func ClientPayouts ¶
func ClientPayouts(host storage.HostInfo, funding common.BigInt, basePrice common.BigInt, baseCollateral common.BigInt, period uint64, expectedStorage uint64) (clientPayout common.BigInt, hostPayout common.BigInt, hostCollateral common.BigInt, err error)
ClientPayouts calculate client and host collateral
func PubkeyToEnodeID ¶
PubkeyToEnodeID calculate Enode.ContractID, reference: p2p/discover/node.go:41 p2p/discover/node.go:59
func RentPaymentValidation ¶
func RentPaymentValidation(rent storage.RentPayment) (err error)
RentPaymentValidation will validate the rentPayment. All fields must be non-zero value
Types ¶
type ContractManager ¶
type ContractManager struct {
// contains filtered or unexported fields
}
ContractManager is a data structure that is used to keep track of all contracts, including both signed contracts and expired contracts
func New ¶
func New(persistDir string, hm *storagehostmanager.StorageHostManager) (cm *ContractManager, err error)
New will initialize the ContractManager object, which is used for contract maintenance
func (*ContractManager) AcquireRentPayment ¶
func (cm *ContractManager) AcquireRentPayment() (rentPayment storage.RentPayment)
AcquireRentPayment will return the RentPayment settings
func (*ContractManager) CalculatePeriodCost ¶
func (cm *ContractManager) CalculatePeriodCost(rentPayment storage.RentPayment) (periodCost storage.PeriodCost)
CalculatePeriodCost will calculate the storage client's cost for one period (including all contracts)
func (*ContractManager) ContractCreate ¶
func (cm *ContractManager) ContractCreate(params storage.ContractParams) (md storage.ContractMetaData, err error)
ContractCreate will try to create the contract with the storage host manager provided by the caller
func (*ContractManager) ContractRenew ¶
func (cm *ContractManager) ContractRenew(oldContract *contractset.Contract, params storage.ContractParams) (md storage.ContractMetaData, err error)
ContractRenew renew transaction initiated by the storage client
func (*ContractManager) GetStorageContractSet ¶
func (cm *ContractManager) GetStorageContractSet() (contractSet *contractset.StorageContractSet)
GetStorageContractSet will be used to get the contract set stored with active contracts
func (*ContractManager) HostHealthMap ¶
func (cm *ContractManager) HostHealthMap() (infoTable storage.HostHealthInfoTable)
HostHealthMap returns all storage host information and contract information from active contract list
func (*ContractManager) HostHealthMapByID ¶
func (cm *ContractManager) HostHealthMapByID(hostIDs []enode.ID) (infoTable storage.HostHealthInfoTable)
HostHealthMapByID return storage.HostHealthInfoTable for hosts specified by the output
func (*ContractManager) InsertRandomActiveContracts ¶
func (cm *ContractManager) InsertRandomActiveContracts(amount int) (err error)
InsertRandomActiveContracts will create some random contracts and inserted into active contract list
func (*ContractManager) RetrieveActiveContract ¶
func (cm *ContractManager) RetrieveActiveContract(contractID storage.ContractID) (contract storage.ContractMetaData, exists bool)
RetrieveActiveContract will return the contract meta data based on the contract id provided
func (*ContractManager) RetrieveActiveContracts ¶
func (cm *ContractManager) RetrieveActiveContracts() (cms []storage.ContractMetaData)
RetrieveActiveContracts will be used to retrieve all the signed contracts
func (*ContractManager) RetrievePeriodCost ¶
func (cm *ContractManager) RetrievePeriodCost() storage.PeriodCost
RetrievePeriodCost will get the client's period cost which specifies cost that storage client needs to pay within one period cycle. It includes cost for all contracts
func (*ContractManager) RetrieveRateLimit ¶
func (cm *ContractManager) RetrieveRateLimit() (readBPS, writeBPS int64, packetSize uint64)
RetrieveRateLimit will acquire the current rate limit
func (*ContractManager) SetRateLimits ¶
func (cm *ContractManager) SetRateLimits(readBPS int64, writeBPS int64, packetSize uint64)
SetRateLimits will set the rate limits for the active contracts, which limited the data upload, download speed, and the packet size per upload/download
func (*ContractManager) SetRentPayment ¶
func (cm *ContractManager) SetRentPayment(rent storage.RentPayment, market hostMarket) (err error)
SetRentPayment will set the rent payment to the value passed in by the user through the command line interface
func (*ContractManager) Start ¶
func (cm *ContractManager) Start(b storage.ClientBackend) (err error)
Start will start the contract manager by loading the prior settings, subscribe the the block chain change event, save the settings, and set rentPayment payment for storage host manager
func (*ContractManager) Stop ¶
func (cm *ContractManager) Stop()
Stop will send stop signal to threadManager, terminate all running go routines