You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
469 B
22 lines
469 B
package main
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"net/http"
|
|
|
|
"github.com/mediocregopher/blog.mediocregopher.com/srv/pow"
|
|
)
|
|
|
|
func newPowChallengeHandler(mgr pow.Manager) http.Handler {
|
|
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
|
challenge := mgr.NewChallenge()
|
|
|
|
jsonResult(rw, r, struct {
|
|
Seed string `json:"seed"`
|
|
Target uint32 `json:"target"`
|
|
}{
|
|
Seed: hex.EncodeToString(challenge.Seed),
|
|
Target: challenge.Target,
|
|
})
|
|
})
|
|
}
|
|
|