github.com/dmmcquay/sia@v1.3.1-0.20180712220038-9f8d535311b9/doc/api/HostDB.md (about)

     1  Host DB API
     2  ===========
     3  
     4  This document contains detailed descriptions of the hostdb's API routes. For an
     5  overview of the hostdb's API routes, see [API.md#host-db](/doc/API.md#host-db).
     6  For an 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 hostdb maintains a database of all hosts known to the network. The database
    16  identifies hosts by their public key and keeps track of metrics such as price.
    17  
    18  Index
    19  -----
    20  
    21  | Request                                                 | HTTP Verb | Examples                      |
    22  | ------------------------------------------------------- | --------- | ----------------------------- |
    23  | [/hostdb](#hostdb-get-example)                          | GET       | [HostDB Get](#hostdb-get)     |
    24  | [/hostdb/active](#hostdbactive-get-example)             | GET       | [Active hosts](#active-hosts) |
    25  | [/hostdb/all](#hostdball-get-example)                   | GET       | [All hosts](#all-hosts)       |
    26  | [/hostdb/hosts/___:pubkey___](#hostdbhosts-get-example) | GET       | [Hosts](#hosts)               |
    27  
    28  #### /hostdb [GET] [(example)](#hostdb-get)
    29  
    30  shows some general information about the state of the hostdb.
    31  
    32  ###### JSON Response 
    33  
    34  Either the following JSON struct or an error response. See [#standard-responses](#standard-responses).
    35  
    36  ```javascript
    37  {
    38      "initialscancomplete": false // indicates if all known hosts have been scanned at least once.
    39  }
    40  ```
    41  
    42  #### /hostdb/active [GET] [(example)](#active-hosts)
    43  
    44  lists all of the active hosts known to the renter, sorted by preference.
    45  
    46  ###### Query String Parameters
    47  ```
    48  // Number of hosts to return. The actual number of hosts returned may be less
    49  // if there are insufficient active hosts. Optional, the default is all active
    50  // hosts.
    51  numhosts
    52  ```
    53  
    54  ###### JSON Response
    55  ```javascript
    56  {
    57    "hosts": [
    58      {
    59        // true if the host is accepting new contracts.
    60        "acceptingcontracts": true,
    61  
    62        // Maximum number of bytes that the host will allow to be requested by a
    63        // single download request.
    64        "maxdownloadbatchsize": 17825792,
    65  
    66        // Maximum duration in blocks that a host will allow for a file contract.
    67        // The host commits to keeping files for the full duration under the
    68        // threat of facing a large penalty for losing or dropping data before
    69        // the duration is complete. The storage proof window of an incoming file
    70        // contract must end before the current height + maxduration.
    71        //
    72        // There is a block approximately every 10 minutes.
    73        // e.g. 1 day = 144 blocks
    74        "maxduration": 25920,
    75  
    76        // Maximum size in bytes of a single batch of file contract
    77        // revisions. Larger batch sizes allow for higher throughput as there is
    78        // significant communication overhead associated with performing a batch
    79        // upload.
    80        "maxrevisebatchsize": 17825792,
    81  
    82        // Remote address of the host. It can be an IPv4, IPv6, or hostname,
    83        // along with the port. IPv6 addresses are enclosed in square brackets.
    84        "netaddress": "123.456.789.0:9982",
    85  
    86        // Unused storage capacity the host claims it has, in bytes.
    87        "remainingstorage": 35000000000,
    88  
    89        // Smallest amount of data in bytes that can be uploaded or downloaded to
    90        // or from the host.
    91        "sectorsize": 4194304,
    92  
    93        // Total amount of storage capacity the host claims it has, in bytes.
    94        "totalstorage": 35000000000,
    95  
    96        // Address at which the host can be paid when forming file contracts.
    97        "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab",
    98  
    99        // A storage proof window is the number of blocks that the host has to
   100        // get a storage proof onto the blockchain. The window size is the
   101        // minimum size of window that the host will accept in a file contract.
   102        "windowsize": 144,
   103  
   104        // Public key used to identify and verify hosts.
   105        "publickey": {
   106          // Algorithm used for signing and verification. Typically "ed25519".
   107          "algorithm": "ed25519",
   108  
   109          // Key used to verify signed host messages.
   110          "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU="
   111        }
   112      }
   113    ]
   114  }
   115  ```
   116  
   117  #### /hostdb/all [GET] [(example)](#all-hosts)
   118  
   119  lists all of the hosts known to the renter. Hosts are not guaranteed to be in
   120  any particular order, and the order may change in subsequent calls.
   121  
   122  ###### JSON Response
   123  ```javascript
   124  {
   125    "hosts": [
   126      {
   127        // true if the host is accepting new contracts.
   128        "acceptingcontracts": true,
   129  
   130        // Maximum number of bytes that the host will allow to be requested by a
   131        // single download request.
   132        "maxdownloadbatchsize": 17825792,
   133  
   134        // Maximum duration in blocks that a host will allow for a file contract.
   135        // The host commits to keeping files for the full duration under the
   136        // threat of facing a large penalty for losing or dropping data before
   137        // the duration is complete. The storage proof window of an incoming file
   138        // contract must end before the current height + maxduration.
   139        //
   140        // There is a block approximately every 10 minutes.
   141        // e.g. 1 day = 144 blocks
   142        "maxduration": 25920,
   143  
   144        // Maximum size in bytes of a single batch of file contract
   145        // revisions. Larger batch sizes allow for higher throughput as there is
   146        // significant communication overhead associated with performing a batch
   147        // upload.
   148        "maxrevisebatchsize": 17825792,
   149  
   150        // Remote address of the host. It can be an IPv4, IPv6, or hostname,
   151        // along with the port. IPv6 addresses are enclosed in square brackets.
   152        "netaddress": "123.456.789.0:9982",
   153  
   154        // Unused storage capacity the host claims it has, in bytes.
   155        "remainingstorage": 35000000000,
   156  
   157        // Smallest amount of data in bytes that can be uploaded or downloaded to
   158        // or from the host.
   159        "sectorsize": 4194304,
   160  
   161        // Total amount of storage capacity the host claims it has, in bytes.
   162        "totalstorage": 35000000000,
   163  
   164        // Address at which the host can be paid when forming file contracts.
   165        "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab",
   166  
   167        // A storage proof window is the number of blocks that the host has to
   168        // get a storage proof onto the blockchain. The window size is the
   169        // minimum size of window that the host will accept in a file contract.
   170        "windowsize": 144,
   171  
   172        // Public key used to identify and verify hosts.
   173        "publickey": {
   174          // Algorithm used for signing and verification. Typically "ed25519".
   175          "algorithm": "ed25519",
   176  
   177          // Key used to verify signed host messages.
   178          "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU="
   179        }
   180      }
   181    ]
   182  }
   183  ```
   184  
   185  #### /hostdb/hosts/___:pubkey___ [GET] [(example)](#hosts)
   186  
   187  fetches detailed information about a particular host, including metrics
   188  regarding the score of the host within the database. It should be noted that
   189  each renter uses different metrics for selecting hosts, and that a good score on
   190  in one hostdb does not mean that the host will be successful on the network
   191  overall.
   192  
   193  ###### Path Parameters
   194  ```
   195  // The public key of the host. Each public key identifies a single host.
   196  //
   197  // Example Pubkey: ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
   198  
   199  :pubkey
   200  ```
   201  
   202  ###### JSON Response
   203  ```javascript
   204  {
   205    "entry": {
   206      // true if the host is accepting new contracts.
   207      "acceptingcontracts": true,
   208  
   209      // Maximum number of bytes that the host will allow to be requested by a
   210      // single download request.
   211      "maxdownloadbatchsize": 17825792,
   212  
   213      // Maximum duration in blocks that a host will allow for a file contract.
   214      // The host commits to keeping files for the full duration under the
   215      // threat of facing a large penalty for losing or dropping data before
   216      // the duration is complete. The storage proof window of an incoming file
   217      // contract must end before the current height + maxduration.
   218      //
   219      // There is a block approximately every 10 minutes.
   220      // e.g. 1 day = 144 blocks
   221      "maxduration": 25920,
   222  
   223      // Maximum size in bytes of a single batch of file contract
   224      // revisions. Larger batch sizes allow for higher throughput as there is
   225      // significant communication overhead associated with performing a batch
   226      // upload.
   227      "maxrevisebatchsize": 17825792,
   228  
   229      // Remote address of the host. It can be an IPv4, IPv6, or hostname,
   230      // along with the port. IPv6 addresses are enclosed in square brackets.
   231      "netaddress": "123.456.789.0:9982",
   232  
   233      // Unused storage capacity the host claims it has, in bytes.
   234      "remainingstorage": 35000000000,
   235  
   236      // Smallest amount of data in bytes that can be uploaded or downloaded to
   237      // or from the host.
   238      "sectorsize": 4194304,
   239  
   240      // Total amount of storage capacity the host claims it has, in bytes.
   241      "totalstorage": 35000000000,
   242  
   243      // Address at which the host can be paid when forming file contracts.
   244      "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab",
   245  
   246      // A storage proof window is the number of blocks that the host has to
   247      // get a storage proof onto the blockchain. The window size is the
   248      // minimum size of window that the host will accept in a file contract.
   249      "windowsize": 144,
   250  
   251      // Public key used to identify and verify hosts.
   252      "publickey": {
   253        // Algorithm used for signing and verification. Typically "ed25519".
   254        "algorithm": "ed25519",
   255  
   256        // Key used to verify signed host messages.
   257        "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU="
   258      },
   259  
   260      // The string representation of the full public key, used when calling
   261      // /hostdb/hosts.
   262      "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
   263    },
   264  
   265    // A set of scores as determined by the renter. Generally, the host's final
   266    // final score is all of the values multiplied together. Modified renters may
   267    // have additional criteria that they use to judge a host, or may ignore
   268    // certin criteia. In general, these fields should only be used as a loose
   269    // guide for the score of a host, as every renter sees the world differently
   270    // and uses different metrics to evaluate hosts.
   271    "scorebreakdown": {
   272  	// The overall score for the host. Scores are entriely relative, and are
   273  	// consistent only within the current hostdb. Between different machines,
   274  	// different configurations, and different versions the absolute scores for
   275  	// a given host can be off by many orders of magnitude. When displaying to a
   276  	// human, some form of normalization with respect to the other hosts (for
   277  	// example, divide all scores by the median score of the hosts) is
   278  	// recommended.
   279  	"score":                      123456,
   280  
   281      // The multiplier that gets applied to the host based on how long it has
   282      // been a host. Older hosts typically have a lower penalty.
   283      "ageadjustment":              0.1234,
   284  
   285      // The multiplier that gets applied to the host based on how much
   286      // proof-of-burn the host has performed. More burn causes a linear increase
   287      // in score.
   288      "burnadjustment":             23.456,
   289  
   290      // The multiplier that gets applied to a host based on how much collateral
   291      // the host is offering. More collateral is typically better, though above
   292      // a point it can be detrimental.
   293      "collateraladjustment":       23.456,
   294  
   295      // The multipler that gets applied to a host based on previous interactions
   296      // with the host. A high ratio of successful interactions will improve this
   297      // hosts score, and a high ratio of failed interactions will hurt this
   298      // hosts score. This adjustment helps account for hosts that are on
   299      // unstable connections, don't keep their wallets unlocked, ran out of
   300      // funds, etc.
   301      "interactionadjustment":      0.1234,
   302  
   303      // The multiplier that gets applied to a host based on the host's price.
   304      // Lower prices are almost always better. Below a certain, very low price,
   305      // there is no advantage.
   306      "priceadjustment":            0.1234,
   307  
   308      // The multiplier that gets applied to a host based on how much storage is
   309      // remaining for the host. More storage remaining is better, to a point.
   310      "storageremainingadjustment": 0.1234,
   311  
   312      // The multiplier that gets applied to a host based on the uptime percentage
   313      // of the host. The penalty increases extremely quickly as uptime drops
   314      // below 90%.
   315      "uptimeadjustment":           0.1234,
   316  
   317      // The multiplier that gets applied to a host based on the version of Sia
   318      // that they are running. Versions get penalties if there are known bugs,
   319      // scaling limitations, performance limitations, etc. Generally, the most
   320      // recent version is always the one with the highest score.
   321      "versionadjustment":          0.1234
   322    }
   323  }
   324  ```
   325  
   326  Examples
   327  --------
   328  
   329  #### HostDB Get
   330  
   331  ###### Request
   332  ```
   333  /hostdb
   334  ```
   335  
   336  ###### Expected Response Code
   337  ```
   338  200 OK
   339  ```
   340  
   341  ###### Example JSON Response
   342  ```javascript
   343  {
   344      "initialscancomplete": false
   345  }
   346  ```
   347  
   348  #### Active hosts
   349  
   350  ###### Request
   351  ```
   352  /hostdb/active?numhosts=2
   353  ```
   354  
   355  ###### Expected Response Code
   356  ```
   357  200 OK
   358  ```
   359  
   360  ###### Example JSON Response
   361  ```javascript
   362  {
   363    "hosts": [
   364      {
   365        "acceptingcontracts": true,
   366        "maxdownloadbatchsize": 17825792,
   367        "maxduration": 25920,
   368        "maxrevisebatchsize": 17825792,
   369        "netaddress": "123.456.789.0:9982",
   370        "remainingstorage": 35000000000,
   371        "sectorsize": 4194304,
   372        "totalstorage": 35000000000,
   373        "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab",
   374        "windowsize": 144,
   375        "publickey": {
   376          "algorithm": "ed25519",
   377          "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU="
   378        }
   379        "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
   380      },
   381      {
   382        "acceptingcontracts": true,
   383        "maxdownloadbatchsize": 17825792,
   384        "maxduration": 25920,
   385        "maxrevisebatchsize": 17825792,
   386        "netaddress": "123.456.789.1:9982",
   387        "remainingstorage": 314,
   388        "sectorsize": 4194304,
   389        "totalstorage": 314159265359,
   390        "unlockhash": "ba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210",
   391        "windowsize": 144,
   392        "publickey": {
   393          "algorithm": "ed25519",
   394          "key": "WWVzIEJydWNlIFNjaG5laWVyIGNhbiByZWFkIHRoaXM="
   395        }
   396        "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
   397      }
   398    ]
   399  }
   400  ```
   401  
   402  #### All hosts
   403  
   404  ###### Request
   405  ```
   406  /hostdb/all
   407  ```
   408  
   409  ###### Expected Response Code
   410  ```
   411  200 OK
   412  ```
   413  
   414  ###### Example JSON Response
   415  ```javascript
   416  {
   417    "hosts": [
   418      {
   419        "acceptingcontracts": false,
   420        "maxdownloadbatchsize": 17825792,
   421        "maxduration": 25920,
   422        "maxrevisebatchsize": 17825792,
   423        "netaddress": "123.456.789.2:9982",
   424        "remainingstorage": 314,
   425        "sectorsize": 4194304,
   426        "totalstorage": 314159265359,
   427        "unlockhash": "abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789",
   428        "windowsize": 144,
   429        "publickey": {
   430          "algorithm": "ed25519",
   431          "key": "SSByYW4gb3V0IG9mIDMyIGNoYXIgbG9uZyBqb2tlcy4="
   432        }
   433        "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
   434      },
   435      {
   436        "acceptingcontracts": true,
   437        "maxdownloadbatchsize": 17825792,
   438        "maxduration": 25920,
   439        "maxrevisebatchsize": 17825792,
   440        "netaddress": "123.456.789.0:9982",
   441        "remainingstorage": 35000000000,
   442        "sectorsize": 4194304,
   443        "totalstorage": 35000000000,
   444        "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab",
   445        "windowsize": 144,
   446        "publickey": {
   447          "algorithm": "ed25519",
   448          "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU="
   449        }
   450        "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
   451      },
   452      {
   453        "acceptingcontracts": true,
   454        "maxdownloadbatchsize": 17825792,
   455        "maxduration": 25920,
   456        "maxrevisebatchsize": 17825792,
   457        "netaddress": "123.456.789.1:9982",
   458        "remainingstorage": 314,
   459        "sectorsize": 4194304,
   460        "totalstorage": 314159265359,
   461        "unlockhash": "ba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210",
   462        "windowsize": 144,
   463        "publickey": {
   464          "algorithm": "ed25519",
   465          "key": "WWVzIEJydWNlIFNjaG5laWVyIGNhbiByZWFkIHRoaXM="
   466        }
   467        "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
   468      }
   469    ]
   470  }
   471  ```
   472  
   473  #### Hosts
   474  
   475  ###### Request
   476  ```
   477  /hostdb/hosts/ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
   478  ```
   479  
   480  ###### Expected Response Code
   481  ```
   482  200 OK
   483  ```
   484  
   485  ###### Example JSON Response
   486  ```javascript
   487  {
   488    "entry": {
   489      "acceptingcontracts": false,
   490      "maxdownloadbatchsize": 17825792,
   491      "maxduration": 25920,
   492      "maxrevisebatchsize": 17825792,
   493      "netaddress": "123.456.789.2:9982",
   494      "remainingstorage": 314,
   495      "sectorsize": 4194304,
   496      "totalstorage": 314159265359,
   497      "unlockhash": "abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789",
   498      "windowsize": 144,
   499      "publickey": {
   500        "algorithm": "ed25519",
   501        "key": "SSByYW4gb3V0IG9mIDMyIGNoYXIgbG9uZyBqb2tlcy4="
   502      }
   503      "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
   504    },
   505    "scorebreakdown": {
   506      "ageadjustment": 0.1234,
   507      "burnadjustment": 0.1234,
   508      "collateraladjustment": 23.456,
   509      "priceadjustment": 0.1234,
   510      "storageremainingadjustment": 0.1234,
   511      "uptimeadjustment": 0.1234,
   512      "versionadjustment": 0.1234,
   513    }
   514  }
   515  ```