fountain: decode peer id (#1593)

Co-authored-by: Travis Person <travisperson@users.noreply.github.com>
This commit is contained in:
Travis Person 2020-04-24 00:34:31 +00:00 committed by GitHub
parent 88ccd73139
commit 1b6aa537d3

View File

@ -16,7 +16,7 @@ import (
"github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-core/peer"
"golang.org/x/xerrors"
"gopkg.in/urfave/cli.v2"
@ -94,6 +94,11 @@ var runCmd = &cli.Command{
return xerrors.Errorf("parsing source address (provide correct --from flag!): %w", err)
}
defaultMinerPeer, err := peer.Decode("12D3KooWJpBNhwgvoZ15EB1JwRTRpxgM9D2fwq6eEktrJJG74aP6")
if err != nil {
return err
}
h := &handler{
ctx: ctx,
api: nodeApi,
@ -114,6 +119,7 @@ var runCmd = &cli.Command{
WalletRate: 1 * time.Hour,
WalletBurst: 2,
}),
defaultMinerPeer: defaultMinerPeer,
}
http.Handle("/", http.FileServer(rice.MustFindBox("site").HTTPBox()))
@ -141,6 +147,8 @@ type handler struct {
limiter *Limiter
minerLimiter *Limiter
defaultMinerPeer peer.ID
}
func (h *handler) send(w http.ResponseWriter, r *http.Request) {
@ -277,7 +285,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
Owner: owner,
Worker: owner,
SectorSize: abi.SectorSize(ssize),
Peer: peer.ID("12D3KooWJpBNhwgvoZ15EB1JwRTRpxgM9D2fwq6eEktrJJG74aP6"),
Peer: h.defaultMinerPeer,
})
if err != nil {
w.WriteHeader(400)