github.com/johnathanhowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/modules/host.go (about) 1 package modules 2 3 import ( 4 "github.com/NebulousLabs/Sia/types" 5 ) 6 7 const ( 8 // HostDir names the directory that contains the host persistence. 9 HostDir = "host" 10 ) 11 12 var ( 13 // BytesPerTerabyte is conversion rate between bytes and terabytes. 14 BytesPerTerabyte = types.NewCurrency64(1e12) 15 16 // BlockBytesPerMonthTerabyte is the conversion rate between block-bytes and month-TB. 17 BlockBytesPerMonthTerabyte = BytesPerTerabyte.Mul64(4320) 18 ) 19 20 type ( 21 // HostFinancialMetrics provides financial statistics for the host, 22 // including money that is locked in contracts. Though verbose, these 23 // statistics should provide a clear picture of where the host's money is 24 // currently being used. The front end can consolidate stats where desired. 25 // Potential revenue refers to revenue that is available in a file 26 // contract, but the file contract window has not yet closed. 27 HostFinancialMetrics struct { 28 // Every time a renter forms a contract with a host, a contract fee is 29 // paid by the renter. These stats track the total contract fees. 30 ContractCompensation types.Currency `json:"contractcompensation"` 31 PotentialContractCompensation types.Currency `json:"potentialcontractcompensation"` 32 33 // Metrics related to storage proofs, collateral, and submitting 34 // transactions to the blockchain. 35 LockedStorageCollateral types.Currency `json:"lockedstoragecollateral"` 36 LostRevenue types.Currency `json:"lostrevenue"` 37 LostStorageCollateral types.Currency `json:"loststoragecollateral"` 38 PotentialStorageRevenue types.Currency `json:"potentialerevenue"` 39 RiskedStorageCollateral types.Currency `json:"riskedstoragecollateral"` 40 StorageRevenue types.Currency `json:"storagerevenue"` 41 TransactionFeeExpenses types.Currency `json:"transactionfeeexpenses"` 42 43 // Bandwidth financial metrics. 44 DownloadBandwidthRevenue types.Currency `json:"downloadbandwidthrevenue"` 45 PotentialDownloadBandwidthRevenue types.Currency `json:"potentialdownloadbandwidthrevenue"` 46 PotentialUploadBandwidthRevenue types.Currency `json:"potentialuploadbandwidthrevenue"` 47 UploadBandwidthRevenue types.Currency `json:"uploadbandwidthrevenue"` 48 } 49 50 // HostInternalSettings contains a list of settings that can be changed. 51 HostInternalSettings struct { 52 AcceptingContracts bool `json:"acceptingcontracts"` 53 MaxDuration types.BlockHeight `json:"maxduration"` 54 MaxDownloadBatchSize uint64 `json:"maxdownloadbatchsize"` 55 MaxReviseBatchSize uint64 `json:"maxrevisebatchsize"` 56 NetAddress NetAddress `json:"netaddress"` 57 WindowSize types.BlockHeight `json:"windowsize"` 58 59 Collateral types.Currency `json:"collateral"` 60 CollateralBudget types.Currency `json:"collateralbudget"` 61 MaxCollateral types.Currency `json:"maxcollateral"` 62 63 DownloadLimitGrowth uint64 `json:"downloadlimitgrowth"` // Bytes per second that get added to the limit for how much download bandwidth the host is allowed to use. 64 DownloadLimitCap uint64 `json:"downloadlimitcap"` // The maximum size of the limit for how much download bandwidth the host is allowed to use. 65 DownloadSpeedLimit uint64 `json:"downloadspeedlimit"` // The maximum download speed for all combined host connections. 66 UploadLimitGrowth uint64 `json:"uploadlimitgrowth"` // Bytes per second that get added to the limit for how much upload bandwidth the host is allowed to use. 67 UploadLimitCap uint64 `json:"uploadlimitcap"` // The maximum size of the limit for how much upload bandwidth the host is allowed to use. 68 UploadSpeedLimit uint64 `json:"uploadspeedlimit"` // The maximum upload speed for all combined host connections. 69 70 MinimumContractPrice types.Currency `json:"contractprice"` 71 MinimumDownloadBandwidthPrice types.Currency `json:"minimumdownloadbandwidthprice"` 72 MinimumStoragePrice types.Currency `json:"storageprice"` 73 MinimumUploadBandwidthPrice types.Currency `json:"minimumuploadbandwidthprice"` 74 } 75 76 // HostNetworkMetrics reports the quantity of each type of RPC call that 77 // has been made to the host. 78 HostNetworkMetrics struct { 79 DownloadBandwidthConsumed uint64 `json:"downloadbandwidthconsumed"` 80 UploadBandwidthConsumed uint64 `json:"uploadbandwidthconsumed"` 81 82 DownloadCalls uint64 `json:"downloadcalls"` 83 ErrorCalls uint64 `json:"errorcalls"` 84 FormContractCalls uint64 `json:"formcontractcalls"` 85 RenewCalls uint64 `json:"renewcalls"` 86 ReviseCalls uint64 `json:"revisecalls"` 87 SettingsCalls uint64 `json:"settingscalls"` 88 UnrecognizedCalls uint64 `json:"unrecognizedcalls"` 89 } 90 91 // A Host can take storage from disk and offer it to the network, managing 92 // things such as announcements, settings, and implementing all of the RPCs 93 // of the host protocol. 94 Host interface { 95 // Announce submits a host announcement to the blockchain. 96 Announce() error 97 98 // AnnounceAddress submits an announcement using the given address. 99 AnnounceAddress(NetAddress) error 100 101 ExternalSettings() HostExternalSettings 102 103 // FinancialMetrics returns the financial statistics of the host. 104 FinancialMetrics() HostFinancialMetrics 105 106 // InternalSettings returns the host's internal settings. 107 InternalSettings() HostInternalSettings 108 109 // NetworkMetrics returns information on the types of RPC calls that 110 // have been made to the host. 111 NetworkMetrics() HostNetworkMetrics 112 113 // SetInternalSettings sets the hosting parameters of the host. 114 SetInternalSettings(HostInternalSettings) error 115 116 // The storage manager provides an interface for adding and removing 117 // storage folders and data sectors to the host. 118 StorageManager 119 } 120 )