storagehostmanager

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: 25 Imported by: 3

Documentation

Index

Constants

View Source
const (
	PersistStorageHostManagerHeader  = "Storage Host Manager Settings"
	PersistStorageHostManagerVersion = "1.0"
	PersistFilename                  = "storagehostmanager.json"
)

StorageHostManager related constant

Variables

This section is empty.

Functions

This section is empty.

Types

type EvaluationDetail

type EvaluationDetail struct {
	Evaluation int64 `json:"evaluation"`

	PresenceScore         float64 `json:"presenceScore"`
	DepositScore          float64 `json:"depositScore"`
	InteractionScore      float64 `json:"interactionScore"`
	ContractPriceScore    float64 `json:"contract_priceScore"`
	StorageRemainingScore float64 `json:"storage_remainingScore"`
	UptimeScore           float64 `json:"uptimeScore"`
}

EvaluationDetail contains the detailed storage host evaluation factors

type FilterMode

type FilterMode int

FilterMode defines a list of storage host that needs to be filtered there are four kinds of filter mode defined below

const (
	DisableFilter FilterMode = iota
	WhitelistFilter
	BlacklistFilter
)

Two kinds of filter mode

  1. disable: filter mode is not allowed
  2. whitelist: only the storage host in both whitelist will be inserted into filteredTree
  3. blacklist: the storage host in the blacklist will not be inserted into filteredTree

func ToFilterMode

func ToFilterMode(fm string) (filterMode FilterMode, err error)

ToFilterMode is used to convert the string formatted filterMode to FilterMode format

func (FilterMode) String

func (fm FilterMode) String() string

String will convert the filter mode into string, used for displaying purpose

type HostEvaluator

type HostEvaluator interface {
	EvaluateDetail(info storage.HostInfo) EvaluationDetail
	Evaluate(info storage.HostInfo) int64
}

HostEvaluator defines an interface that include methods that used to calculate the storage host Evaluate and EvaluateDetail

type InteractionType

type InteractionType uint8

InteractionType is the code for interactions

const (
	// InteractionInvalid is the code that's not valid
	InteractionInvalid InteractionType = iota

	// InteractionGetConfig is the code for client's get config interaction
	InteractionGetConfig

	// InteractionCreateContract is the interaction code for client's create contract
	// negotiation
	InteractionCreateContract

	// InteractionRenewContract is the interaction code for client's renew contract
	// negotiation
	InteractionRenewContract

	// InteractionUpload is the interaction code for client's upload negotiation
	InteractionUpload

	// InteractionDownload is the interaction code for client's download negotiation
	InteractionDownload
)

func InteractionNameToType

func InteractionNameToType(name string) InteractionType

InteractionNameToType translate the human readable interaction name to type

func (InteractionType) String

func (it InteractionType) String() string

String return the string representation of the InteractionType

type PrivateStorageHostManagerAPI

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

PrivateStorageHostManagerAPI defines the object used to call eligible APIs that are used to configure settings

func NewPrivateStorageHostManagerAPI

func NewPrivateStorageHostManagerAPI(shm *StorageHostManager) *PrivateStorageHostManagerAPI

NewPrivateStorageHostManagerAPI initialize PrivateStorageHostManagerAPI object which implemented a bunch of API methods

func (*PrivateStorageHostManagerAPI) SetFilterMode

func (api *PrivateStorageHostManagerAPI) SetFilterMode(fm string, hostInfos []enode.ID) (resp string, err error)

SetFilterMode will be used to change the current storage host manager filter mode settings. There are total of 3 filter modes available

type PublicHostManagerDebugAPI

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

PublicHostManagerDebugAPI defines the object used to call eligible APIs that are used to perform testing

func NewPublicStorageClientDebugAPI

func NewPublicStorageClientDebugAPI(shm *StorageHostManager) *PublicHostManagerDebugAPI

NewPublicStorageClientDebugAPI initialize PublicStorageClientDebugAPI object which implemented a bunch of debug API methods

func (*PublicHostManagerDebugAPI) BlockHeight

func (api *PublicHostManagerDebugAPI) BlockHeight() uint64

BlockHeight will be used to retrieve the current block height stored in the storage host manager data structure. If everything function correctly, the block height it returned should be same as the blockheight it synced

func (*PublicHostManagerDebugAPI) InsertActiveHostInfo

func (api *PublicHostManagerDebugAPI) InsertActiveHostInfo(amount int) string

InsertActiveHostInfo will insert active host information into the storage host tree all host information are generated randomly. NOTE: if the information is not checked immediately, those active hosts will became inactive because of failing to establish connection

func (*PublicHostManagerDebugAPI) InsertHostInfo

func (api *PublicHostManagerDebugAPI) InsertHostInfo(amount int) string

InsertHostInfo will insert host information into the storage host tree all host information are generated randomly

func (*PublicHostManagerDebugAPI) InsertHostInfoHighEval

func (api *PublicHostManagerDebugAPI) InsertHostInfoHighEval(id enode.ID) (err error)

InsertHostInfoHighEval is used for the test case in contractManager module, which is used to insert contract with higher evaluation

func (*PublicHostManagerDebugAPI) InsertHostInfoIPTime

func (api *PublicHostManagerDebugAPI) InsertHostInfoIPTime(amount int, id enode.ID, ip string, ipChanged time.Time) (err error)

InsertHostInfoIPTime is used for the test case in contractManager module

func (*PublicHostManagerDebugAPI) InsertHostInfoLowEval

func (api *PublicHostManagerDebugAPI) InsertHostInfoLowEval(id enode.ID) (err error)

InsertHostInfoLowEval is used for the test case in contractManager module, which is used to insert contract with lower evaluation (evaluation that is smaller than 1)

func (*PublicHostManagerDebugAPI) Online

func (api *PublicHostManagerDebugAPI) Online() bool

Online will be used to indicate if the local node is connected to the internet or not by checking the number of peers it connected width

func (*PublicHostManagerDebugAPI) RetrieveRentPaymentInfo

func (api *PublicHostManagerDebugAPI) RetrieveRentPaymentInfo() (rentPayment storage.RentPayment)

RetrieveRentPaymentInfo is used to get the rentPayment settings, which is used for debugging purposes

func (*PublicHostManagerDebugAPI) Syncing

func (api *PublicHostManagerDebugAPI) Syncing() bool

Syncing will be used to indicate if the local node is currently syncing with the blockchain

type PublicStorageHostManagerAPI

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

PublicStorageHostManagerAPI defines the object used to call eligible public APIs that are used to acquire storage host information

func NewPublicStorageHostManagerAPI

func NewPublicStorageHostManagerAPI(shm *StorageHostManager) *PublicStorageHostManagerAPI

NewPublicStorageHostManagerAPI initialize PublicStorageHostManagerAPI object which implemented a bunch of API methods

func (*PublicStorageHostManagerAPI) ActiveStorageHosts

func (api *PublicStorageHostManagerAPI) ActiveStorageHosts() (activeStorageHosts []storage.HostInfo)

ActiveStorageHosts returns active storage host information

func (*PublicStorageHostManagerAPI) AllStorageHosts

func (api *PublicStorageHostManagerAPI) AllStorageHosts() (allStorageHosts []storage.HostInfo)

AllStorageHosts will return all storage hosts information stored from the storage host pool

func (*PublicStorageHostManagerAPI) FilterMode

func (api *PublicStorageHostManagerAPI) FilterMode() (fm string)

FilterMode will return the current storage host manager filter mode setting

func (*PublicStorageHostManagerAPI) FilteredHosts

func (api *PublicStorageHostManagerAPI) FilteredHosts() (allFiltered []storage.HostInfo)

FilteredHosts will return hosts stored in the filtered host tree

func (*PublicStorageHostManagerAPI) StorageHost

func (api *PublicStorageHostManagerAPI) StorageHost(id string) storage.HostInfo

StorageHost will return a specific host detailed information from the storage host pool

func (*PublicStorageHostManagerAPI) StorageHostRanks

func (api *PublicStorageHostManagerAPI) StorageHostRanks() (rankings []StorageHostRank)

StorageHostRanks will return the storage host rankings based on their evaluations. The higher the evaluation is, the higher order it will be placed

type StorageHostManager

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

StorageHostManager contains necessary fields that are used to manage storage hosts establishing connection with them and getting their settings

func New

func New(persistDir string) *StorageHostManager

New will initialize HostPoolManager, making the host pool stay updated

func (*StorageHostManager) ActiveStorageHosts

func (shm *StorageHostManager) ActiveStorageHosts() (activeStorageHosts []storage.HostInfo)

ActiveStorageHosts will return all active storage host information

func (*StorageHostManager) AllHosts

func (shm *StorageHostManager) AllHosts() []storage.HostInfo

AllHosts will return all available storage hosts

func (*StorageHostManager) Close

func (shm *StorageHostManager) Close() error

Close will send stop signal to routine manager, terminate all the running go routines

func (*StorageHostManager) Evaluate

func (shm *StorageHostManager) Evaluate(host storage.HostInfo) int64

Evaluate will calculate and return the evaluation of a single storage host

func (*StorageHostManager) FilterIPViolationHosts

func (shm *StorageHostManager) FilterIPViolationHosts(hostIDs []enode.ID) (badHostIDs []enode.ID)

FilterIPViolationHosts will evaluate the storage hosts passed in. For hosts located under the same network, it will be considered as badHosts if the IPViolation is enabled

func (*StorageHostManager) GetMarketPrice

func (shm *StorageHostManager) GetMarketPrice() storage.MarketPrice

GetMarketPrice will return the market price. It will first try to get the value from cached prices. If cached prices need to be updated, prices are calculated and returned. Note that the function need to be protected by shm.lock for shm.initialScanFinished field.

func (*StorageHostManager) IncrementFailedInteractions

func (shm *StorageHostManager) IncrementFailedInteractions(id enode.ID, interactionType InteractionType)

IncrementFailedInteractions will update storage host's interactions factors

func (*StorageHostManager) IncrementSuccessfulInteractions

func (shm *StorageHostManager) IncrementSuccessfulInteractions(id enode.ID, interactionType InteractionType)

IncrementSuccessfulInteractions will update storage host's interactions factors

func (*StorageHostManager) RetrieveFilterMode

func (shm *StorageHostManager) RetrieveFilterMode() (fm string)

RetrieveFilterMode will get the storage host manager filter mode information

func (*StorageHostManager) RetrieveHostInfo

func (shm *StorageHostManager) RetrieveHostInfo(id enode.ID) (hi storage.HostInfo, exists bool)

RetrieveHostInfo will acquire the storage host information based on the enode ID provided. Before returning the storage host information, the settings will be validated first

func (*StorageHostManager) RetrieveIPViolationCheckSetting

func (shm *StorageHostManager) RetrieveIPViolationCheckSetting() (violationCheck bool)

RetrieveIPViolationCheckSetting will return the current tipViolationCheck

func (*StorageHostManager) RetrieveRandomHosts

func (shm *StorageHostManager) RetrieveRandomHosts(num int, blacklist, addrBlacklist []enode.ID) (infos []storage.HostInfo, err error)

RetrieveRandomHosts will randomly select storage hosts from the storage host pool

  1. blacklist represents the storage host that are prohibited to be selected
  2. addrBlacklist represents for any storage host whose network address is caontine

func (*StorageHostManager) RetrieveRentPayment

func (shm *StorageHostManager) RetrieveRentPayment() (rent storage.RentPayment)

RetrieveRentPayment will return the current rent payment settings for storage host manager

func (*StorageHostManager) SetFilterMode

func (shm *StorageHostManager) SetFilterMode(fm FilterMode, hostInfo []enode.ID) error

SetFilterMode will be used to set the host ip filter mode. Actions are required only when the mode is set to be whitelist, meaning that only the storage host in both whitelist and hostPool can be inserted into the filteredTree

func (*StorageHostManager) SetIPViolationCheck

func (shm *StorageHostManager) SetIPViolationCheck(violationCheck bool)

SetIPViolationCheck will set the ipViolationCheck to be true. For storage hosts who are located in the same network, they will be marked as bad storage hosts

func (*StorageHostManager) SetRentPayment

func (shm *StorageHostManager) SetRentPayment(rent storage.RentPayment) (err error)

SetRentPayment will modify the rent payment and update the host evaluations in storage host tree as well as filtered tree

func (*StorageHostManager) Start

Start will start to load prior settings, start go routines to automatically save the settings every 2 min, and go routine to start storage host maintenance

func (*StorageHostManager) StorageHostRanks

func (shm *StorageHostManager) StorageHostRanks() (rankings []StorageHostRank)

StorageHostRanks will return the storage host rankings based on their evaluations. The higher the evaluation is, the higher order it will be placed

type StorageHostRank

type StorageHostRank struct {
	EvaluationDetail
	EnodeID string
}

StorageHostRank will be used to show the rankings of the storage host learnt by the storage client

Jump to

Keyboard shortcuts

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