github.com/fozzysec/SiaPrime@v0.0.0-20190612043147-66c8e8d11fe3/doc/api/Host.md (about) 1 Host API 2 -------- 3 4 This document contains detailed descriptions of the host's API routes. For an 5 overview of the host's API routes, see [API.md#host](/doc/API.md#host). For an 6 overview of all API routes, see [API.md](/doc/API.md) 7 8 There may be functional API calls which are not documented. These are not 9 guaranteed to be supported beyond the current release, and should not be used 10 in production. 11 12 Overview 13 -------- 14 15 The host provides storage from local disks to the network. The host negotiates 16 file contracts with remote renters to earn money for storing other users' 17 files. The host's endpoints expose methods for viewing and modifying host 18 settings, announcing to the network, and managing how files are stored on disk. 19 20 Index 21 ----- 22 23 | Route | HTTP verb | 24 | ------------------------------------------------------------------------------------------ | --------- | 25 | [/host](#host-get) | GET | 26 | [/host](#host-post) | POST | 27 | [/host/announce](#hostannounce-post) | POST | 28 | [/host/contracts](#hostcontracts-get) | GET | 29 | [/host/estimatescore](#hostestimatescore-get) | GET | 30 | [/host/storage](#hoststorage-get) | GET | 31 | [/host/storage/folders/add](#hoststoragefoldersadd-post) | POST | 32 | [/host/storage/folders/remove](#hoststoragefoldersremove-post) | POST | 33 | [/host/storage/folders/resize](#hoststoragefoldersresize-post) | POST | 34 | [/host/storage/sectors/delete/:___merkleroot___](#hoststoragesectorsdeletemerkleroot-post) | POST | 35 36 37 #### /host [GET] 38 39 fetches status information about the host. 40 41 ###### JSON Response 42 ```javascript 43 { 44 // The settings that get displayed to untrusted nodes querying the host's 45 // status. 46 "externalsettings": { 47 // Whether or not the host is accepting new contracts. 48 "acceptingcontracts": true, 49 50 // The maximum size of a single download request from a renter. Each 51 // download request has multiple round trips of communication that 52 // exchange money. Larger batch sizes mean fewer round trips, but more 53 // financial risk for the host - the renter can get a free batch when 54 // downloading by refusing to provide a signature. 55 "maxdownloadbatchsize": 17825792, // bytes 56 57 // The maximum duration that a host will allow for a file contract. The 58 // host commits to keeping files for the full duration under the threat 59 // of facing a large penalty for losing or dropping data before the 60 // duration is complete. The storage proof window of an incoming file 61 // contract must end before the current height + maxduration. 62 "maxduration": 25920, // blocks 63 64 // The maximum size of a single batch of file contract revisions. The 65 // renter can perform DoS attacks on the host by uploading a batch of 66 // data then refusing to provide a signature to pay for the data. The 67 // host can reduce this exposure by limiting the batch size. Larger 68 // batch sizes allow for higher throughput as there is significant 69 // communication overhead associated with performing a batch upload. 70 "maxrevisebatchsize": 17825792, // bytes 71 72 // The IP address or hostname (including port) that the host should be 73 // contacted at. 74 "netaddress": "123.456.789.0:4282", 75 76 // The amount of unused storage capacity on the host in bytes. It 77 // should be noted that the host can lie. 78 "remainingstorage": 35000000000, // bytes 79 80 // The smallest amount of data in bytes that can be uploaded or 81 // downloaded when performing calls to the host. 82 "sectorsize": 4194304, // bytes 83 84 // The total amount of storage capacity on the host. It should be noted 85 // that the host can lie. 86 "totalstorage": 35000000000, // bytes 87 88 // The unlock hash is the address at which the host can be paid when 89 // forming file contracts. 90 "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 91 92 // The storage proof window is the number of blocks that the host has 93 // to get a storage proof onto the blockchain. The window size is the 94 // minimum size of window that the host will accept in a file contract. 95 "windowsize": 144, // blocks 96 97 // The maximum amount of money that the host will put up as collateral 98 // for storage that is contracted by the renter. 99 "collateral": "57870370370", // hastings / byte / block 100 101 // The maximum amount of collateral that the host will put into a 102 // single file contract. 103 "maxcollateral": "100000000000000000000000000000", // hastings 104 105 // The price that a renter has to pay to create a contract with the 106 // host. The payment is intended to cover transaction fees 107 // for the file contract revision and the storage proof that the host 108 // will be submitting to the blockchain. 109 "contractprice": "30000000000000000000000000", // hastings 110 111 // The price that a renter has to pay when downloading data from the 112 // host. 113 "downloadbandwidthprice": "250000000000000", // hastings / byte 114 115 // The price that a renter has to pay to store files with the host. 116 "storageprice": "231481481481", // hastings / byte / block 117 118 // The price that a renter has to pay when uploading data to the host. 119 "uploadbandwidthprice": "100000000000000", // hastings / byte 120 121 // The revision number indicates to the renter what iteration of 122 // settings the host is currently at. Settings are generally signed. 123 // If the renter has multiple conflicting copies of settings from the 124 // host, the renter can expect the one with the higher revision number 125 // to be more recent. 126 "revisionnumber": 0, 127 128 // The version of external settings being used. This field helps 129 // coordinate updates while preserving compatibility with older nodes. 130 "version": "1.0.0" 131 }, 132 133 // The financial status of the host. 134 "financialmetrics": { 135 // Number of open file contracts. 136 "contractcount": 2, 137 138 // The amount of money that renters have given to the host to pay for 139 // file contracts. The host is required to submit a file contract 140 // revision and a storage proof for every file contract that gets created, 141 // and the renter pays for the miner fees on these objects. 142 "contractcompensation": "123", // hastings 143 144 // The amount of money that renters have given to the host to pay for 145 // file contracts which have not been confirmed yet. The potential 146 // compensation becomes compensation after the storage proof is 147 // submitted. 148 "potentialcontractcompensation": "123", // hastings 149 150 // The amount of storage collateral which the host has tied up in file 151 // contracts. The host has to commit collateral to a file contract even 152 // if there is no storage, but the locked collateral will be returned 153 // even if the host does not submit a storage proof - the collateral is 154 // not at risk, it is merely set aside so that it can be put at risk 155 // later. 156 "lockedstoragecollateral": "123", // hastings 157 158 // The amount of revenue, including storage revenue and bandwidth 159 // revenue, that has been lost due to failed file contracts and 160 // failed storage proofs. 161 "lostrevenue": "123", // hastings 162 163 // The amount of collateral that was put up to protect data which has 164 // been lost due to failed file contracts and missed storage proofs. 165 "loststoragecollateral": "123", // hastings 166 167 // The amount of revenue that the host stands to earn if all storage 168 // proofs are submitted corectly and in time. 169 "potentialstoragerevenue": "123", // hastings 170 171 // The amount of money that the host has risked on file contracts. If 172 // the host starts missing storage proofs, the host can forfeit up to 173 // this many coins. In the event of a missed storage proof, locked 174 // storage collateral gets returned, but risked storage collateral 175 // does not get returned. 176 "riskedstoragecollateral": "123", // hastings 177 178 // The amount of money that the host has earned from storing data. This 179 // money has been locked down by successful storage proofs. 180 "storagerevenue": "123", // hastings 181 182 // The amount of money that the host has spent on transaction fees when 183 // submitting host announcements, file contract revisions, and storage 184 // proofs. 185 "transactionfeeexpenses": "123", // hastings 186 187 // The amount of money that the host has made from renters downloading 188 // their files. This money has been locked in by successsful storage 189 // proofs. 190 "downloadbandwidthrevenue": "123", // hastings 191 192 // The amount of money that the host stands to make from renters that 193 // downloaded their files. The host will only realize this revenue if 194 // the host successfully submits storage proofs for the related file 195 // contracts. 196 "potentialdownloadbandwidthrevenue": "123", // hastings 197 198 // The amount of money that the host stands to make from renters that 199 // uploaded files. The host will only realize this revenue if the host 200 // successfully submits storage proofs for the related file contracts. 201 "potentialuploadbandwidthrevenue": "123", // hastings 202 203 // The amount of money that the host has made from renters uploading 204 // their files. This money has been locked in by successful storage 205 // proofs. 206 "uploadbandwidthrevenue": "123" // hastings 207 }, 208 209 // The settings of the host. Most interactions between the user and the 210 // host occur by changing the internal settings. 211 "internalsettings": { 212 // When set to true, the host will accept new file contracts if the 213 // terms are reasonable. When set to false, the host will not accept new 214 // file contracts at all. 215 "acceptingcontracts": true, 216 217 // The maximum size of a single download request from a renter. Each 218 // download request has multiple round trips of communication that 219 // exchange money. Larger batch sizes mean fewer round trips, but more 220 // financial risk for the host - the renter can get a free batch when 221 // downloading by refusing to provide a signature. 222 "maxdownloadbatchsize": 17825792, // bytes 223 224 // The maximum duration of a file contract that the host will accept. 225 // The storage proof window must end before the current height + 226 // maxduration. 227 "maxduration": 25920, // blocks 228 229 // The maximum size of a single batch of file contract revisions. The 230 // renter can perform DoS attacks on the host by uploading a batch of 231 // data then refusing to provide a signature to pay for the data. The 232 // host can reduce this exposure by limiting the batch size. Larger 233 // batch sizes allow for higher throughput as there is significant 234 // communication overhead associated with performing a batch upload. 235 "maxrevisebatchsize": 17825792, // bytes 236 237 // The IP address or hostname (including port) that the host should be 238 // contacted at. If left blank, the host will automatically figure out 239 // its ip address and use that. If given, the host will use the address 240 // given. 241 "netaddress": "123.456.789.0:4282", 242 243 // The storage proof window is the number of blocks that the host has 244 // to get a storage proof onto the blockchain. The window size is the 245 // minimum size of window that the host will accept in a file contract. 246 "windowsize": 144, // blocks 247 248 // The maximum amount of money that the host will put up as collateral 249 // per byte per block of storage that is contracted by the renter. 250 "collateral": "57870370370", // hastings / byte / block 251 252 // The total amount of money that the host will allocate to collateral 253 // across all file contracts. 254 "collateralbudget": "2000000000000000000000000000000", // hastings 255 256 // The maximum amount of collateral that the host will put into a 257 // single file contract. 258 "maxcollateral": "100000000000000000000000000000", // hastings 259 260 // The minimum price that the host will demand from a renter when 261 // forming a contract. Typically this price is to cover transaction 262 // fees on the file contract revision and storage proof, but can also 263 // be used if the host has a low amount of collateral. The price is a 264 // minimum because the host may automatically adjust the price upwards 265 // in times of high demand. 266 "mincontractprice": "30000000000000000000000000", // hastings 267 268 // The minimum price that the host will demand from a renter when the 269 // renter is downloading data. If the host is saturated, the host may 270 // increase the price from the minimum. 271 "mindownloadbandwidthprice": "250000000000000", // hastings / byte 272 273 // The minimum price that the host will demand when storing data for 274 // extended periods of time. If the host is low on space, the price of 275 // storage may be set higher than the minimum. 276 "minstorageprice": "231481481481", // hastings / byte / block 277 278 // The minimum price that the host will demand from a renter when the 279 // renter is uploading data. If the host is saturated, the host may 280 // increase the price from the minimum. 281 "minuploadbandwidthprice": "100000000000000" // hastings / byte 282 }, 283 284 // Information about the network, specifically various ways in which 285 // renters have contacted the host. 286 "networkmetrics": { 287 // The number of times that a renter has attempted to download 288 // something from the host. 289 "downloadcalls": 0, 290 291 // The number of calls that have resulted in errors. A small number of 292 // errors are expected, but a large number of errors indicate either 293 // buggy software or malicious network activity. Usually buggy 294 // software. 295 "errorcalls": 1, 296 297 // The number of times that a renter has tried to form a contract with 298 // the host. 299 "formcontractcalls": 2, 300 301 // The number of times that a renter has tried to renew a contract with 302 // the host. 303 "renewcalls": 3, 304 305 // The number of times that the renter has tried to revise a contract 306 // with the host. 307 "revisecalls": 4, 308 309 // The number of times that a renter has queried the host for the 310 // host's settings. The settings include the price of bandwidth, which 311 // is a price that can adjust every few minutes. This value is usually 312 // very high compared to the others. 313 "settingscalls": 5, 314 315 // The number of times that a renter has attempted to use an 316 // unrecognized call. Larger numbers typically indicate buggy software. 317 "unrecognizedcalls": 6 318 }, 319 320 // Information about the health of the host. 321 322 // connectabilitystatus is one of "checking", "connectable", 323 // or "not connectable", and indicates if the host can connect to 324 // itself on its configured NetAddress. 325 "connectabilitystatus": "checking", 326 327 // workingstatus is one of "checking", "working", or "not working" 328 // and indicates if the host is being actively used by renters. 329 "workingstatus": "checking" 330 } 331 ``` 332 333 #### /host [POST] 334 335 configures hosting parameters. All parameters are optional; unspecified 336 parameters will be left unchanged. 337 338 ###### Query String Parameters 339 ``` 340 // When set to true, the host will accept new file contracts if the 341 // terms are reasonable. When set to false, the host will not accept new 342 // file contracts at all. 343 acceptingcontracts // Optional, true / false 344 345 // The maximum size of a single download request from a renter. Each 346 // download request has multiple round trips of communication that 347 // exchange money. Larger batch sizes mean fewer round trips, but more 348 // financial risk for the host - the renter can get a free batch when 349 // downloading by refusing to provide a signature. 350 maxdownloadbatchsize // Optional, bytes 351 352 // The maximum duration of a file contract that the host will accept. 353 // The storage proof window must end before the current height + 354 // maxduration. 355 maxduration // Optional, blocks 356 357 // The maximum size of a single batch of file contract revisions. The 358 // renter can perform DoS attacks on the host by uploading a batch of 359 // data then refusing to provide a signature to pay for the data. The 360 // host can reduce this exposure by limiting the batch size. Larger 361 // batch sizes allow for higher throughput as there is significant 362 // communication overhead associated with performing a batch upload. 363 maxrevisebatchsize // Optional, bytes 364 365 // The IP address or hostname (including port) that the host should be 366 // contacted at. If left blank, the host will automatically figure out 367 // its ip address and use that. If given, the host will use the address 368 // given. 369 netaddress // Optional 370 371 // The storage proof window is the number of blocks that the host has 372 // to get a storage proof onto the blockchain. The window size is the 373 // minimum size of window that the host will accept in a file contract. 374 windowsize // Optional, blocks 375 376 // The maximum amount of money that the host will put up as collateral 377 // per byte per block of storage that is contracted by the renter. 378 collateral // Optional, hastings / byte / block 379 380 // The total amount of money that the host will allocate to collateral 381 // across all file contracts. 382 collateralbudget // Optional, hastings 383 384 // The maximum amount of collateral that the host will put into a 385 // single file contract. 386 maxcollateral // Optional, hastings 387 388 // The minimum price that the host will demand from a renter when 389 // forming a contract. Typically this price is to cover transaction 390 // fees on the file contract revision and storage proof, but can also 391 // be used if the host has a low amount of collateral. The price is a 392 // minimum because the host may automatically adjust the price upwards 393 // in times of high demand. 394 mincontractprice // Optional, hastings 395 396 // The minimum price that the host will demand from a renter when the 397 // renter is downloading data. If the host is saturated, the host may 398 // increase the price from the minimum. 399 mindownloadbandwidthprice // Optional, hastings / byte 400 401 // The minimum price that the host will demand when storing data for 402 // extended periods of time. If the host is low on space, the price of 403 // storage may be set higher than the minimum. 404 minstorageprice // Optional, hastings / byte / block 405 406 // The minimum price that the host will demand from a renter when the 407 // renter is uploading data. If the host is saturated, the host may 408 // increase the price from the minimum. 409 minuploadbandwidthprice // Optional, hastings / byte 410 ``` 411 412 ###### Response 413 standard success or error response. See 414 [#standard-responses](#standard-responses). 415 416 #### /host/announce [POST] 417 418 Announce the host to the network as a source of storage. Generally only needs 419 to be called once. 420 421 Note that even after the host has been announced, it will not accept new 422 contracts unless configured to do so. To configure the host to accept 423 contracts, see [/host](https://gitlab.com/SiaPrime/SiaPrime/blob/master/doc/api/Host.md#host-post). 424 425 ###### Query String Parameters 426 ``` 427 // The address to be announced. If no address is provided, the automatically 428 // discovered address will be used instead. 429 netaddress string // Optional 430 ``` 431 432 ###### Response 433 standard success or error response. See 434 [#standard-responses](#standard-responses). 435 436 #### /host/contracts [GET] 437 438 Get contract information from the host database. This call will return all storage obligations on the host. Its up to the caller to filter the contracts based on his needs. 439 440 ###### JSON Response 441 ```javascript 442 { 443 "contracts": [ 444 // Amount in hastings to cover the transaction fees for this storage obligation. 445 "contractcost": "1234", // hastings 446 447 // Size of the data that is protected by the contract. 448 "datasize": 50000, // bytes 449 450 // Amount that is locked as collateral for this storage obligation. 451 "lockedcollateral": "1234", // hastings 452 453 // Id of the storageobligation, which is defined by the file contract id of the file contract that governs the storage obligation. 454 "obligationid": "fff48010dcbbd6ba7ffd41bc4b25a3634ee58bbf688d2f06b7d5a0c837304e13", 455 456 // Potential revenue for downloaded data that the host will reveive upon successful completion of the obligation. 457 "potentialdownloadrevenue": "1234", // hastings 458 459 // Potential revenue for storage of data that the host will reveive upon successful completion of the obligation. 460 "potentialstoragerevenue": "1234", // hastings 461 462 // Potential revenue for uploaded data that the host will reveive upon successful completion of the obligation. 463 "potentialuploadrevenue": "1234", // hastings 464 465 // Amount that the host might lose if the submission of the storage proof is not successful. 466 "riskedcollateral": "1234", // hastings 467 468 // Number of sector roots. 469 "sectorrootscount": 2, 470 471 // Amount for transaction fees that the host added to the storage obligation. 472 "transactionfeesadded": "1234", // hastings 473 474 // Experation height is the height at which the storage obligation expires. 475 "expirationheight": 123456, // blocks 476 477 // Negotion height is the height at which the storage obligation was negotiated. 478 "negotiationheight": 0, // blocks 479 480 // The proof deadline is the height by which the storage proof must be submitted. 481 "proofdeadline": 123456, // blocks 482 483 // Status of the storage obligation. There are 4 different statuses: 484 // obligationFailed: the storage obligation failed, potential revenues and risked collateral are lost 485 // obligationRejected: the storage obligation was never started, no revenues gained or lost 486 // obligationSucceeded: the storage obligation was completed, revenues were gained 487 // obligationUnresolved: the storage obligation has an uninitialized value. When the "proofdeadline" is in the past this might be a stale obligation. 488 "obligationstatus": "obligationFailed", 489 490 // Origin confirmed indicates whether the file contract was seen on the blockchain for this storage obligation. 491 "originconfirmed": true, 492 493 // Proof confirmed indicates whether there was a storage proof seen on the blockchain for this storage obligation. 494 "proofconfirmed": true, 495 496 // The host has constructed a storage proof 497 "proofconstructed": false 498 499 // Revision confirmed indicates whether there was a file contract revision seen on the blockchain for this storage obligation. 500 "revisionconfirmed": true, 501 502 // Revision constructed indicates whether there was a file contract revision constructed for this storage obligation. 503 "revisionconstructed": true, 504 ] 505 } 506 ``` 507 508 #### /host/storage [GET] 509 510 gets a list of folders tracked by the host's storage manager. 511 512 ###### JSON Response 513 ```javascript 514 { 515 "folders": [ 516 { 517 // Absolute path to the storage folder on the local filesystem. 518 "path": "/home/foo/bar", 519 520 // Maximum capacity of the storage folder. The host will not store more 521 // than this many bytes in the folder. This capacity is not checked 522 // against the drive's remaining capacity. Therefore, you must manually 523 // ensure the disk has sufficient capacity for the folder at all times. 524 // Otherwise you risk losing renter's data and failing storage proofs. 525 "capacity": 50000000000, // bytes 526 527 // Unused capacity of the storage folder. 528 "capacityremaining": 100000, // bytes 529 530 // Number of failed disk read & write operations. A large number of 531 // failed reads or writes indicates a problem with the filesystem or 532 // drive's hardware. 533 "failedreads": 0, 534 "failedwrites": 1, 535 536 // Number of successful read & write operations. 537 "successfulreads": 2, 538 "successfulwrites": 3 539 } 540 ] 541 } 542 ``` 543 544 #### /host/storage/folders/add [POST] 545 546 adds a storage folder to the manager. The manager may not check that there is 547 enough space available on-disk to support as much storage as requested 548 549 ###### Query String Parameters 550 ``` 551 // Local path on disk to the storage folder to add. 552 path // Required 553 554 // Initial capacity of the storage folder. This value isn't validated so it is 555 // possible to set the capacity of the storage folder greater than the capacity 556 // of the disk. Do not do this. 557 size // bytes, Required 558 ``` 559 560 ###### Response 561 standard success or error response. See 562 [#standard-responses](#standard-responses). 563 564 #### /host/storage/folders/remove [POST] 565 566 remove a storage folder from the manager. All storage on the folder will be 567 moved to other storage folders, meaning that no data will be lost. If the 568 manager is unable to save data, an error will be returned and the operation 569 will be stopped. 570 571 ###### Query String Parameters 572 ``` 573 // Local path on disk to the storage folder to remove. 574 path // Required 575 576 // If `force` is true, the storage folder will be removed even if the data in 577 // the storage folder cannot be moved to other storage folders, typically 578 // because they don't have sufficient capacity. If `force` is true and the data 579 // cannot be moved, data will be lost. 580 force // bool, Optional, default is false 581 ``` 582 583 ###### Response 584 standard success or error response. See 585 [#standard-responses](#standard-responses). 586 587 #### /host/storage/folders/resize [POST] 588 589 grows or shrink a storage folder in the manager. The manager may not check that 590 there is enough space on-disk to support growing the storage folder, but should 591 gracefully handle running out of space unexpectedly. When shrinking a storage 592 folder, any data in the folder that needs to be moved will be placed into other 593 storage folders, meaning that no data will be lost. If the manager is unable to 594 migrate the data, an error will be returned and the operation will be stopped. 595 596 ###### Query String Parameters 597 ``` 598 // Local path on disk to the storage folder to resize. 599 path // Required 600 601 // Desired new size of the storage folder. This will be the new capacity of the 602 // storage folder. 603 newsize // bytes, Required 604 ``` 605 606 ###### Response 607 standard success or error response. See 608 [#standard-responses](#standard-responses). 609 610 #### /host/storage/sectors/delete/___*merkleroot___ [POST] 611 612 deletes a sector, meaning that the manager will be unable to upload that sector 613 and be unable to provide a storage proof on that sector. This endpoint is for 614 removing the data entirely, and will remove instances of the sector appearing 615 at all heights. The primary purpose is to comply with legal requests to remove 616 data. 617 618 ###### Path Parameters 619 ``` 620 // Merkleroot of the sector to delete. 621 :merkleroot 622 ``` 623 624 ###### Response 625 standard success or error response. See 626 [#standard-responses](#standard-responses). 627 628 #### /host/estimatescore [GET] 629 630 returns the estimated HostDB score of the host using its current settings, 631 combined with the provided settings. 632 633 ###### JSON Response 634 ```javascript 635 { 636 // estimatedscore is the estimated HostDB score of the host given the 637 // settings passed to estimatescore. 638 "estimatedscore": "123456786786786786786786786742133", 639 // conversionrate is the likelihood given the settings passed to 640 // estimatescore that the host will be selected by renters forming contracts. 641 "conversionrate": 95 642 } 643 ``` 644 645 ###### Query String Parameters 646 ``` 647 acceptingcontracts // Optional, true / false 648 maxdownloadbatchsize // Optional, bytes 649 maxduration // Optional, blocks 650 maxrevisebatchsize // Optional, bytes 651 netaddress // Optional 652 windowsize // Optional, blocks 653 654 collateral // Optional, hastings / byte / block 655 collateralbudget // Optional, hastings 656 maxcollateral // Optional, hastings 657 658 mincontractprice // Optional, hastings 659 mindownloadbandwidthprice // Optional, hastings / byte 660 minstorageprice // Optional, hastings / byte / block 661 minuploadbandwidthprice // Optional, hastings / byte 662 ``` 663