gitlab.com/SiaPrime/SiaPrime@v1.4.1/node/api/client/hostdb.go (about) 1 package client 2 3 import ( 4 "encoding/json" 5 6 "gitlab.com/SiaPrime/SiaPrime/modules" 7 "gitlab.com/SiaPrime/SiaPrime/node/api" 8 "gitlab.com/SiaPrime/SiaPrime/types" 9 ) 10 11 // HostDbGet requests the /hostdb endpoint's resources. 12 func (c *Client) HostDbGet() (hdg api.HostdbGet, err error) { 13 err = c.get("/hostdb", &hdg) 14 return 15 } 16 17 // HostDbActiveGet requests the /hostdb/active endpoint's resources. 18 func (c *Client) HostDbActiveGet() (hdag api.HostdbActiveGET, err error) { 19 err = c.get("/hostdb/active", &hdag) 20 return 21 } 22 23 // HostDbAllGet requests the /hostdb/all endpoint's resources. 24 func (c *Client) HostDbAllGet() (hdag api.HostdbAllGET, err error) { 25 err = c.get("/hostdb/all", &hdag) 26 return 27 } 28 29 // HostDbFilterModeGet requests the /hostdb/filtermode GET endpoint 30 func (c *Client) HostDbFilterModeGet() (hdfmg api.HostdbFilterModeGET, err error) { 31 err = c.get("/hostdb/filtermode", &hdfmg) 32 return 33 } 34 35 // HostDbFilterModePost requests the /hostdb/filtermode POST endpoint 36 func (c *Client) HostDbFilterModePost(fm modules.FilterMode, hosts []types.SiaPublicKey) (err error) { 37 filterMode := fm.String() 38 hdblp := api.HostdbFilterModePOST{ 39 FilterMode: filterMode, 40 Hosts: hosts, 41 } 42 43 data, err := json.Marshal(hdblp) 44 if err != nil { 45 return err 46 } 47 err = c.post("/hostdb/FilterMode", string(data), nil) 48 return 49 } 50 51 // HostDbHostsGet request the /hostdb/hosts/:pubkey endpoint's resources. 52 func (c *Client) HostDbHostsGet(pk types.SiaPublicKey) (hhg api.HostdbHostsGET, err error) { 53 err = c.get("/hostdb/hosts/"+pk.String(), &hhg) 54 return 55 }