Commit 60b4cfd2 authored by Luke Champine's avatar Luke Champine

add /host/announce API call

parent 39ad578c
package main
/*
import (
"fmt"
......@@ -27,9 +26,16 @@ var (
hostSetConfigCmd = &cobra.Command{
Use: "setconfig [totalstorage] [maxfilesize] [mintolerance] [maxduration] [price] [burn]",
Short: "Modify host settings",
Long: "Modify host settings, including available storage, price, and more. The new settings will be be announced to the network.",
Long: "Modify host settings, including available storage, price, and more.",
Run: wrap(hostsetconfigcmd),
}
hostAnnounceCmd = &cobra.Command{
Use: "announce",
Short: "Announce host",
Long: "Announce yourself as a host on the network. You may wish to set your hosting parameters first, via 'host setconfig'.",
Run: wrap(hostannouncecmd),
}
)
func hostconfigcmd() {
......@@ -60,4 +66,12 @@ func hostsetconfigcmd(totalstorage, maxfilesize, mintolerance, maxduration, pric
}
fmt.Println("Host settings updated. You have been announced as a host on the network.")
}
*/
func hostannouncecmd() {
err := callAPI("/host/announce")
if err != nil {
fmt.Println("Could not announce host:", err)
return
}
fmt.Println("Host announcement submitted to network.")
}
......@@ -104,9 +104,8 @@ func main() {
Run: version,
})
// TODO: Bring these back
// root.AddCommand(hostCmd)
// hostCmd.AddCommand(hostConfigCmd, hostSetConfigCmd)
root.AddCommand(hostCmd)
hostCmd.AddCommand(hostConfigCmd, hostSetConfigCmd, hostAnnounceCmd)
root.AddCommand(minerCmd)
minerCmd.AddCommand(minerStartCmd, minerStatusCmd, minerStopCmd)
......
......@@ -14,11 +14,9 @@ func (d *daemon) handle(addr string) {
mux := http.NewServeMux()
// Host API Calls
//
// TODO: SetConfig also calls announce(), there should be smarter ways to
// handle this.
mux.HandleFunc("/host/config", d.hostConfigHandler)
mux.HandleFunc("/host/setconfig", d.hostSetConfigHandler)
mux.HandleFunc("/host/announce", d.hostAnnounceHandler)
// Miner API Calls
mux.HandleFunc("/miner/start", d.minerStartHandler)
......
......@@ -48,11 +48,17 @@ func (d *daemon) hostSetConfigHandler(w http.ResponseWriter, req *http.Request)
http.Error(w, "Could not update host:"+err.Error(), 400)
}
err = d.core.AnnounceHost(1, d.state.Height()+20) // A freeze volume and unlock height.
if err != nil {
http.Error(w, "Could not update host:"+err.Error(), 400)
}
writeSuccess(w)
*/
}
func (d *daemon) hostAnnounceHandler(w http.ResponseWriter, req *http.Request) {
err = d.core.AnnounceHost(1, d.state.Height()+20) // A freeze volume and unlock height.
if err != nil {
http.Error(w, "Could not update host:"+err.Error(), 400)
return
}
writeSuccess(w)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment