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