storagehost

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: Apache-2.0 Imports: 29 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// PersistHostDir is dir path for storing the host log, json, and etc.
	PersistHostDir = "storagehost"
	// Version is the version of the storage host
	Version = "1.0"
	// HostSettingFile is the file name for saving the setting of host
	HostSettingFile = "host.json"

	// StorageManager is a dir for storagemanager related topic
	StorageManager = "storagemanager"
)

Variables

This section is empty.

Functions

func ContractCreateHandler

func ContractCreateHandler(h *StorageHost, sp storage.Peer, contractCreateReqMsg p2p.Msg)

ContractCreateHandler will be used to handle the contract create request sent by the storage client

func DownloadHandler

func DownloadHandler(h *StorageHost, sp storage.Peer, downloadReqMsg p2p.Msg)

DownloadHandler handles the download negotiation

func ExtendErr

func ExtendErr(s string, err error) error

ExtendErr wraps a error with a string

func UploadHandler

func UploadHandler(h *StorageHost, sp storage.Peer, uploadReqMsg p2p.Msg)

UploadHandler handles the upload negotiation

func VerifyRevision

func VerifyRevision(so *StorageResponsibility, revision *types.StorageContractRevision, blockHeight uint64, expectedExchange, expectedCollateral common.BigInt) error

VerifyRevision checks that the revision pays the host correctly, and that the revision does not attempt any malicious or unexpected changes.

Types

type ErrorCreateContract

type ErrorCreateContract string

ErrorCreateContract is some error that occurs in contract creation

func (ErrorCreateContract) Error

func (e ErrorCreateContract) Error() string

type ErrorRevision

type ErrorRevision string

ErrorRevision is some error that occurs in revision

func (ErrorRevision) Error

func (e ErrorRevision) Error() string

type HostFinancialMetrics

type HostFinancialMetrics struct {
	ContractCount                     uint64        `json:"contractcount"`
	ContractCompensation              common.BigInt `json:"contractcompensation"`
	PotentialContractCompensation     common.BigInt `json:"potentialcontractcompensation"`
	LockedStorageDeposit              common.BigInt `json:"lockedstoragedeposit"`
	LostRevenue                       common.BigInt `json:"lostrevenue"`
	LostStorageDeposit                common.BigInt `json:"loststoragedeposit"`
	PotentialStorageRevenue           common.BigInt `json:"potentialstoragerevenue"`
	RiskedStorageDeposit              common.BigInt `json:"riskedstoragedeposit"`
	StorageRevenue                    common.BigInt `json:"storagerevenue"`
	TransactionFeeExpenses            common.BigInt `json:"transactionfeeexpenses"`
	DownloadBandwidthRevenue          common.BigInt `json:"downloadbandwidthrevenue"`
	PotentialDownloadBandwidthRevenue common.BigInt `json:"potentialdownloadbandwidthrevenue"`
	PotentialUploadBandwidthRevenue   common.BigInt `json:"potentialuploadbandwidthrevenue"`
	UploadBandwidthRevenue            common.BigInt `json:"uploadbandwidthrevenue"`
}

HostFinancialMetrics record the financial element for host

type HostFinancialMetricsForDisplay

type HostFinancialMetricsForDisplay struct {
	ContractCount                     uint64 `json:"contractcount"`
	ContractCompensation              string `json:"contractcompensation"`
	PotentialContractCompensation     string `json:"potentialcontractcompensation"`
	LockedStorageDeposit              string `json:"lockedstoragedeposit"`
	LostRevenue                       string `json:"lostrevenue"`
	LostStorageDeposit                string `json:"loststoragedeposit"`
	PotentialStorageRevenue           string `json:"potentialstoragerevenue"`
	RiskedStorageDeposit              string `json:"riskedstoragedeposit"`
	StorageRevenue                    string `json:"storagerevenue"`
	TransactionFeeExpenses            string `json:"transactionfeeexpenses"`
	DownloadBandwidthRevenue          string `json:"downloadbandwidthrevenue"`
	PotentialDownloadBandwidthRevenue string `json:"potentialdownloadbandwidthrevenue"`
	PotentialUploadBandwidthRevenue   string `json:"potentialuploadbandwidthrevenue"`
	UploadBandwidthRevenue            string `json:"uploadbandwidthrevenue"`
}

HostFinancialMetricsForDisplay is the financial metric for display

type HostPrivateAPI

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

HostPrivateAPI is the api for private usage

func NewHostPrivateAPI

func NewHostPrivateAPI(storageHost *StorageHost) *HostPrivateAPI

NewHostPrivateAPI is the api to create the host private api

func (*HostPrivateAPI) AddStorageFolder

func (h *HostPrivateAPI) AddStorageFolder(path string, sizeStr string) (string, error)

AddStorageFolder add a storage folder with a specified size

func (*HostPrivateAPI) Announce

func (h *HostPrivateAPI) Announce() string

Announce set accepting contracts to true, and then send the announcement transaction

func (*HostPrivateAPI) AvailableSpace

func (h *HostPrivateAPI) AvailableSpace() storage.HostSpace

AvailableSpace return the available spaces of the host

func (*HostPrivateAPI) DeleteFolder

func (h *HostPrivateAPI) DeleteFolder(folderPath string) (string, error)

DeleteFolder delete the folder

func (*HostPrivateAPI) Folders

func (h *HostPrivateAPI) Folders() []storage.HostFolder

Folders return all the folders

func (*HostPrivateAPI) GetFinancialMetrics

func (h *HostPrivateAPI) GetFinancialMetrics() HostFinancialMetricsForDisplay

GetFinancialMetrics get the financial metrics of the host

func (*HostPrivateAPI) GetHostConfig

func (h *HostPrivateAPI) GetHostConfig() storage.HostIntConfigForDisplay

GetHostConfig return the internal settings of the storage host

func (*HostPrivateAPI) GetPaymentAddress

func (h *HostPrivateAPI) GetPaymentAddress() string

GetPaymentAddress get the account address used to sign the storage contract. If not configured, the first address in the local wallet will be used as the paymentAddress by default.

func (*HostPrivateAPI) GetProofWindow

func (h *HostPrivateAPI) GetProofWindow() string

GetProofWindow return the proof window size

func (*HostPrivateAPI) PersistDir

func (h *HostPrivateAPI) PersistDir() string

PersistDir print the persist directory of the host

func (*HostPrivateAPI) ResizeFolder

func (h *HostPrivateAPI) ResizeFolder(folderPath string, sizeStr string) (string, error)

ResizeFolder resize the folder to specified size

func (*HostPrivateAPI) SectorSize

func (h *HostPrivateAPI) SectorSize() uint64

SectorSize return the sector size as a basic storage unit of the storage system.

func (*HostPrivateAPI) SetConfig

func (h *HostPrivateAPI) SetConfig(config map[string]string) (string, error)

SetConfig set the config specified by a mapping of key value pair

func (*HostPrivateAPI) Version

func (h *HostPrivateAPI) Version() string

Version gives a mock version of the debugapi

type StorageHost

type StorageHost struct {

	// storage host manager for manipulating the file storage system
	sm.StorageManager
	// contains filtered or unexported fields
}

StorageHost provide functions for storageHost management It loads or use default config when it have been initialized It aims at communicate by protocol with client and lent its own storage to the client

func New

func New(persistDir string) (*StorageHost, error)

New Initialize the Host, including init the structure load or use the default config, init db and ext.

func (*StorageHost) Close

func (h *StorageHost) Close() error

Close the storage host and persist the data

func (*StorageHost) GetCurrentBlockHeight

func (h *StorageHost) GetCurrentBlockHeight() uint64

GetCurrentBlockHeight is used to retrieve the current block height saved in the storage host

func (*StorageHost) GetStorageResponsibility

func (h *StorageHost) GetStorageResponsibility(storageContractID common.Hash) (StorageResponsibility, error)

GetStorageResponsibility will be used to get the storage responsibility information based on the storage contractID provided

func (*StorageHost) IsContractSignedWithClient

func (h *StorageHost) IsContractSignedWithClient(clientNode *enode.Node) bool

IsContractSignedWithClient check whether this host signed a contract with the given client

func (*StorageHost) RetrieveExternalConfig

func (h *StorageHost) RetrieveExternalConfig() storage.HostExtConfig

RetrieveExternalConfig is used to get the storage host's external configuration

func (*StorageHost) Start

func (h *StorageHost) Start(eth storage.HostBackend) (err error)

Start loads all APIs and make them mapping, also introduce the account manager as a member variable in side the StorageHost

func (*StorageHost) UpdateContractToClientNodeMappingAndConnection

func (h *StorageHost) UpdateContractToClientNodeMappingAndConnection()

UpdateContractToClientNodeMappingAndConnection will update the contract that host signed with the storage client. For any contract that are not contained in the storage responsibility, it means host had not signed the contract with the client. The connection will be removed from the static and the contract information will be deleted from the record

type StorageResponsibility

type StorageResponsibility struct {
	//Store the root set of related metadata
	SectorRoots []common.Hash

	//Primary source of income and expenditure
	ContractCost             common.BigInt
	LockedStorageDeposit     common.BigInt
	PotentialDownloadRevenue common.BigInt
	PotentialStorageRevenue  common.BigInt
	PotentialUploadRevenue   common.BigInt
	RiskedStorageDeposit     common.BigInt
	TransactionFeeExpenses   common.BigInt

	//Chain height during negotiation
	NegotiationBlockNumber uint64

	//The initial storage contract
	OriginStorageContract types.StorageContract

	//Revision set
	StorageContractRevisions []types.StorageContractRevision
	ResponsibilityStatus     storageResponsibilityStatus

	CreateContractConfirmed    bool
	StorageProofConfirmed      bool
	StorageProofConstructed    bool
	StorageRevisionConfirmed   bool
	StorageRevisionConstructed bool
}

StorageResponsibility storage contract management and maintenance on the storage host side

func (*StorageResponsibility) ProofDeadline

func (so *StorageResponsibility) ProofDeadline() uint64

ProofDeadline calculates the block number that the proof must submit

type TryMutex

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

TryMutex provides a mutex that allows you to attempt to grab a mutex, and then fail if the mutex is either not grabbed immediately or is not grabbed by the specified duration.

func (*TryMutex) Lock

func (tm *TryMutex) Lock()

Lock grabs a lock on the TryMutex, blocking until the lock is obtained.

func (*TryMutex) TryLock

func (tm *TryMutex) TryLock() bool

TryLock grabs a lock on the TryMutex, returning an error if the mutex is already locked.

func (*TryMutex) TryLockTimed

func (tm *TryMutex) TryLockTimed(t time.Duration) bool

TryLockTimed grabs a lock on the TryMutex, returning an error if the mutex is not grabbed after the provided duration.

func (*TryMutex) Unlock

func (tm *TryMutex) Unlock()

Unlock releases a lock on the TryMutex.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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