Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Move hostdb API endpoints to /hostdb
Browse files Browse the repository at this point in the history
from /renter/hosts
  • Loading branch information
VoidingWarranties committed Jun 27, 2016
1 parent aa120d3 commit 38fecbb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
5 changes: 3 additions & 2 deletions api/api.go
Expand Up @@ -163,8 +163,9 @@ func (srv *Server) initAPI(password string) {
router.POST("/renter/rename/*siapath", requirePassword(srv.renterRenameHandler, password))
router.POST("/renter/upload/*siapath", requirePassword(srv.renterUploadHandler, password))

router.GET("/renter/hosts/active", srv.renterHostsActiveHandler)
router.GET("/renter/hosts/all", srv.renterHostsAllHandler)
// HostDB endpoints.
router.GET("/hostdb/active", srv.renterHostsActiveHandler)
router.GET("/hostdb/all", srv.renterHostsAllHandler)
}

// TransactionPool API Calls
Expand Down
20 changes: 10 additions & 10 deletions api/renter_test.go
Expand Up @@ -124,7 +124,7 @@ func TestRenterConflicts(t *testing.T) {
}

// TestRenterHostsActiveHandler checks the behavior of the call to
// /renter/hosts/active.
// /hostdb/active.
func TestRenterHostsActiveHandler(t *testing.T) {
if testing.Short() {
t.SkipNow()
Expand All @@ -137,25 +137,25 @@ func TestRenterHostsActiveHandler(t *testing.T) {

// Try the call with with numhosts unset, and set to -1, 0, and 1.
var ah ActiveHosts
err = st.getAPI("/renter/hosts/active", &ah)
err = st.getAPI("/hostdb/active", &ah)
if err != nil {
t.Fatal(err)
}
if len(ah.Hosts) != 0 {
t.Fatal(len(ah.Hosts))
}
err = st.getAPI("/renter/hosts/active?numhosts=-1", &ah)
err = st.getAPI("/hostdb/active?numhosts=-1", &ah)
if err == nil {
t.Fatal("expecting an error, got:", err)
}
err = st.getAPI("/renter/hosts/active?numhosts=0", &ah)
err = st.getAPI("/hostdb/active?numhosts=0", &ah)
if err != nil {
t.Fatal(err)
}
if len(ah.Hosts) != 0 {
t.Fatal(len(ah.Hosts))
}
err = st.getAPI("/renter/hosts/active?numhosts=1", &ah)
err = st.getAPI("/hostdb/active?numhosts=1", &ah)
if err != nil {
t.Fatal(err)
}
Expand All @@ -178,32 +178,32 @@ func TestRenterHostsActiveHandler(t *testing.T) {
}

// Try the call with with numhosts unset, and set to -1, 0, 1, and 2.
err = st.getAPI("/renter/hosts/active", &ah)
err = st.getAPI("/hostdb/active", &ah)
if err != nil {
t.Fatal(err)
}
if len(ah.Hosts) != 1 {
t.Fatal(len(ah.Hosts))
}
err = st.getAPI("/renter/hosts/active?numhosts=-1", &ah)
err = st.getAPI("/hostdb/active?numhosts=-1", &ah)
if err == nil {
t.Fatal("expecting an error, got:", err)
}
err = st.getAPI("/renter/hosts/active?numhosts=0", &ah)
err = st.getAPI("/hostdb/active?numhosts=0", &ah)
if err != nil {
t.Fatal(err)
}
if len(ah.Hosts) != 0 {
t.Fatal(len(ah.Hosts))
}
err = st.getAPI("/renter/hosts/active?numhosts=1", &ah)
err = st.getAPI("/hostdb/active?numhosts=1", &ah)
if err != nil {
t.Fatal(err)
}
if len(ah.Hosts) != 1 {
t.Fatal(len(ah.Hosts))
}
err = st.getAPI("/renter/hosts/active?numhosts=2", &ah)
err = st.getAPI("/hostdb/active?numhosts=2", &ah)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions api/server_helpers_test.go
Expand Up @@ -408,13 +408,13 @@ func (st *serverTester) announceHost() error {
}
// wait for announcement
var hosts ActiveHosts
err = st.getAPI("/renter/hosts/active", &hosts)
err = st.getAPI("/hostdb/active", &hosts)
if err != nil {
return err
}
for i := 0; i < 20 && len(hosts.Hosts) == 0; i++ {
time.Sleep(100 * time.Millisecond)
err = st.getAPI("/renter/hosts/active", &hosts)
err = st.getAPI("/hostdb/active", &hosts)
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions doc/API.md
Expand Up @@ -582,8 +582,8 @@ Queries:
* /renter/download/{siapath} [GET]
* /renter/rename/{siapath} [POST]
* /renter/upload/{siapath} [POST]
* /renter/hosts/active [GET]
* /renter/hosts/all [GET]
* /hostdb/active [GET]
* /hostdb/all [GET]

#### /renter/allowance [GET]

Expand Down Expand Up @@ -818,7 +818,7 @@ source string

Response: standard.

#### /renter/hosts/active [GET]
#### /hostdb/active [GET]

Function: Lists all of the active hosts known to the renter, sorted by
preference.
Expand All @@ -845,9 +845,9 @@ struct {
}
}
```
See /renter/hosts/all for a description of each field.
See /hostdb/all for a description of each field.

#### /renter/hosts/all [GET]
#### /hostdb/all [GET]

Function: Lists all of the hosts known to the renter.

Expand Down
2 changes: 1 addition & 1 deletion siac/hostcmd.go
Expand Up @@ -132,7 +132,7 @@ func hostcmd() {
// Determine the competitive price string.
ah := new(api.ActiveHosts)
var competitivePrice string
err = getAPI("/renter/hosts/active?numhosts=24", ah)
err = getAPI("/hostdb/active?numhosts=24", ah)
if err != nil || len(ah.Hosts) == 0 {
competitivePrice = "Unavailable"
} else {
Expand Down
2 changes: 1 addition & 1 deletion siac/hostdbcmd.go
Expand Up @@ -20,7 +20,7 @@ var (

func hostdbcmd() {
info := new(api.ActiveHosts)
err := getAPI("/renter/hosts/active", info)
err := getAPI("/hostdb/active", info)
if err != nil {
die("Could not fetch host list:", err)
}
Expand Down

0 comments on commit 38fecbb

Please sign in to comment.