github.com/fozzysec/SiaPrime@v0.0.0-20190612043147-66c8e8d11fe3/modules/host.go (about) 1 package modules 2 3 import ( 4 "SiaPrime/types" 5 ) 6 7 const ( 8 // HostDir names the directory that contains the host persistence. 9 HostDir = "host" 10 ) 11 12 var ( 13 // BlockBytesPerMonthTerabyte is the conversion rate between block-bytes and month-TB. 14 BlockBytesPerMonthTerabyte = BytesPerTerabyte.Mul64(4320) 15 16 // BytesPerTerabyte is the conversion rate between bytes and terabytes. 17 BytesPerTerabyte = types.NewCurrency64(1e12) 18 19 // HostConnectabilityStatusChecking is returned from ConnectabilityStatus() 20 // if the host is still determining if it is connectable. 21 HostConnectabilityStatusChecking = HostConnectabilityStatus("checking") 22 23 // HostConnectabilityStatusConnectable is returned from 24 // ConnectabilityStatus() if the host is connectable at its configured 25 // netaddress. 26 HostConnectabilityStatusConnectable = HostConnectabilityStatus("connectable") 27 28 // HostConnectabilityStatusNotConnectable is returned from 29 // ConnectabilityStatus() if the host is not connectable at its configured 30 // netaddress. 31 HostConnectabilityStatusNotConnectable = HostConnectabilityStatus("not connectable") 32 33 // HostWorkingStatusChecking is returned from WorkingStatus() if the host is 34 // still determining if it is working, that is, if settings calls are 35 // incrementing. 36 HostWorkingStatusChecking = HostWorkingStatus("checking") 37 38 // HostWorkingStatusNotWorking is returned from WorkingStatus() if the host 39 // has not received any settings calls over the duration of 40 // workingStatusFrequency. 41 HostWorkingStatusNotWorking = HostWorkingStatus("not working") 42 43 // HostWorkingStatusWorking is returned from WorkingStatus() if the host has 44 // received more than workingThreshold settings calls over the duration of 45 // workingStatusFrequency. 46 HostWorkingStatusWorking = HostWorkingStatus("working") 47 ) 48 49 type ( 50 // HostFinancialMetrics provides financial statistics for the host, 51 // including money that is locked in contracts. Though verbose, these 52 // statistics should provide a clear picture of where the host's money is 53 // currently being used. The front end can consolidate stats where desired. 54 // Potential revenue refers to revenue that is available in a file 55 // contract for which the file contract window has not yet closed. 56 HostFinancialMetrics struct { 57 // Every time a renter forms a contract with a host, a contract fee is 58 // paid by the renter. These stats track the total contract fees. 59 ContractCount uint64 `json:"contractcount"` 60 ContractCompensation types.Currency `json:"contractcompensation"` 61 PotentialContractCompensation types.Currency `json:"potentialcontractcompensation"` 62 63 // Metrics related to storage proofs, collateral, and submitting 64 // transactions to the blockchain. 65 LockedStorageCollateral types.Currency `json:"lockedstoragecollateral"` 66 LostRevenue types.Currency `json:"lostrevenue"` 67 LostStorageCollateral types.Currency `json:"loststoragecollateral"` 68 PotentialStorageRevenue types.Currency `json:"potentialstoragerevenue"` 69 RiskedStorageCollateral types.Currency `json:"riskedstoragecollateral"` 70 StorageRevenue types.Currency `json:"storagerevenue"` 71 TransactionFeeExpenses types.Currency `json:"transactionfeeexpenses"` 72 73 // Bandwidth financial metrics. 74 DownloadBandwidthRevenue types.Currency `json:"downloadbandwidthrevenue"` 75 PotentialDownloadBandwidthRevenue types.Currency `json:"potentialdownloadbandwidthrevenue"` 76 PotentialUploadBandwidthRevenue types.Currency `json:"potentialuploadbandwidthrevenue"` 77 UploadBandwidthRevenue types.Currency `json:"uploadbandwidthrevenue"` 78 } 79 80 // HostInternalSettings contains a list of settings that can be changed. 81 HostInternalSettings struct { 82 AcceptingContracts bool `json:"acceptingcontracts"` 83 MaxDownloadBatchSize uint64 `json:"maxdownloadbatchsize"` 84 MaxDuration types.BlockHeight `json:"maxduration"` 85 MaxReviseBatchSize uint64 `json:"maxrevisebatchsize"` 86 NetAddress NetAddress `json:"netaddress"` 87 WindowSize types.BlockHeight `json:"windowsize"` 88 89 Collateral types.Currency `json:"collateral"` 90 CollateralBudget types.Currency `json:"collateralbudget"` 91 MaxCollateral types.Currency `json:"maxcollateral"` 92 93 MinContractPrice types.Currency `json:"mincontractprice"` 94 MinDownloadBandwidthPrice types.Currency `json:"mindownloadbandwidthprice"` 95 MinStoragePrice types.Currency `json:"minstorageprice"` 96 MinUploadBandwidthPrice types.Currency `json:"minuploadbandwidthprice"` 97 } 98 99 // HostNetworkMetrics reports the quantity of each type of RPC call that 100 // has been made to the host. 101 HostNetworkMetrics struct { 102 DownloadCalls uint64 `json:"downloadcalls"` 103 ErrorCalls uint64 `json:"errorcalls"` 104 FormContractCalls uint64 `json:"formcontractcalls"` 105 RenewCalls uint64 `json:"renewcalls"` 106 ReviseCalls uint64 `json:"revisecalls"` 107 SettingsCalls uint64 `json:"settingscalls"` 108 UnrecognizedCalls uint64 `json:"unrecognizedcalls"` 109 } 110 111 // StorageObligation contains information about a storage obligation that 112 // the host has accepted. 113 StorageObligation struct { 114 ContractCost types.Currency `json:"contractcost"` 115 DataSize uint64 `json:"datasize"` 116 LockedCollateral types.Currency `json:"lockedcollateral"` 117 ObligationId types.FileContractID `json:"obligationid"` 118 PotentialDownloadRevenue types.Currency `json:"potentialdownloadrevenue"` 119 PotentialStorageRevenue types.Currency `json:"potentialstoragerevenue"` 120 PotentialUploadRevenue types.Currency `json:"potentialuploadrevenue"` 121 RiskedCollateral types.Currency `json:"riskedcollateral"` 122 SectorRootsCount uint64 `json:"sectorrootscount"` 123 TransactionFeesAdded types.Currency `json:"transactionfeesadded"` 124 125 // The negotiation height specifies the block height at which the file 126 // contract was negotiated. The expiration height and the proof deadline 127 // are equal to the window start and window end. Between the expiration height 128 // and the proof deadline, the host must submit the storage proof. 129 ExpirationHeight types.BlockHeight `json:"expirationheight"` 130 NegotiationHeight types.BlockHeight `json:"negotiationheight"` 131 ProofDeadLine types.BlockHeight `json:"proofdeadline"` 132 133 // Variables indicating whether the critical transactions in a storage 134 // obligation have been confirmed on the blockchain. 135 ObligationStatus string `json:"obligationstatus"` 136 OriginConfirmed bool `json:"originconfirmed"` 137 ProofConfirmed bool `json:"proofconfirmed"` 138 ProofConstructed bool `json:"proofconstructed"` 139 RevisionConfirmed bool `json:"revisionconfirmed"` 140 RevisionConstructed bool `json:"revisionconstructed"` 141 } 142 143 // HostWorkingStatus reports the working state of a host. Can be one of 144 // "checking", "working", or "not working". 145 HostWorkingStatus string 146 147 // HostConnectabilityStatus reports the connectability state of a host. Can be 148 // one of "checking", "connectable", or "not connectable" 149 HostConnectabilityStatus string 150 151 // A Host can take storage from disk and offer it to the network, managing 152 // things such as announcements, settings, and implementing all of the RPCs 153 // of the host protocol. 154 Host interface { 155 // Announce submits a host announcement to the blockchain. 156 Announce() error 157 158 // AnnounceAddress submits an announcement using the given address. 159 AnnounceAddress(NetAddress) error 160 161 // ExternalSettings returns the settings of the host as seen by an 162 // untrusted node querying the host for settings. 163 ExternalSettings() HostExternalSettings 164 165 // FinancialMetrics returns the financial statistics of the host. 166 FinancialMetrics() HostFinancialMetrics 167 168 // InternalSettings returns the host's internal settings, including 169 // potentially private or sensitive information. 170 InternalSettings() HostInternalSettings 171 172 // NetworkMetrics returns information on the types of RPC calls that 173 // have been made to the host. 174 NetworkMetrics() HostNetworkMetrics 175 176 // PublicKey returns the public key of the host. 177 PublicKey() types.SiaPublicKey 178 179 // SetInternalSettings sets the hosting parameters of the host. 180 SetInternalSettings(HostInternalSettings) error 181 182 // StorageObligations returns the set of storage obligations held by 183 // the host. 184 StorageObligations() []StorageObligation 185 186 // ConnectabilityStatus returns the connectability status of the host, that 187 // is, if it can connect to itself on the configured NetAddress. 188 ConnectabilityStatus() HostConnectabilityStatus 189 190 // WorkingStatus returns the working state of the host, determined by if 191 // settings calls are increasing. 192 WorkingStatus() HostWorkingStatus 193 194 // The storage manager provides an interface for adding and removing 195 // storage folders and data sectors to the host. 196 StorageManager 197 } 198 )