Merge pull request #2385 from filecoin-project/feat/fountain-amount

lotus_fountain: add facuet distribution amount flag
This commit is contained in:
Łukasz Magiera 2020-07-13 13:16:19 +02:00 committed by GitHub
commit 4e987163af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,8 +37,6 @@ import (
var log = logging.Logger("main") var log = logging.Logger("main")
var sendPerRequest, _ = types.ParseFIL("50")
var supportedSectors struct { var supportedSectors struct {
SectorSizes []struct { SectorSizes []struct {
Name string Name string
@ -114,8 +112,18 @@ var runCmd = &cli.Command{
&cli.StringFlag{ &cli.StringFlag{
Name: "from", Name: "from",
}, },
&cli.StringFlag{
Name: "amount",
EnvVars: []string{"LOTUS_FOUNTAIN_AMOUNT"},
Value: "50",
},
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
sendPerRequest, err := types.ParseFIL(cctx.String("amount"))
if err != nil {
return err
}
nodeApi, closer, err := lcli.GetFullNodeAPI(cctx) nodeApi, closer, err := lcli.GetFullNodeAPI(cctx)
if err != nil { if err != nil {
return err return err
@ -144,6 +152,7 @@ var runCmd = &cli.Command{
ctx: ctx, ctx: ctx,
api: nodeApi, api: nodeApi,
from: from, from: from,
sendPerRequest: sendPerRequest,
limiter: NewLimiter(LimiterConfig{ limiter: NewLimiter(LimiterConfig{
TotalRate: time.Second, TotalRate: time.Second,
TotalBurst: 256, TotalBurst: 256,
@ -186,6 +195,7 @@ type handler struct {
api api.FullNode api api.FullNode
from address.Address from address.Address
sendPerRequest types.FIL
limiter *Limiter limiter *Limiter
minerLimiter *Limiter minerLimiter *Limiter
@ -266,7 +276,7 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) {
} }
smsg, err := h.api.MpoolPushMessage(h.ctx, &types.Message{ smsg, err := h.api.MpoolPushMessage(h.ctx, &types.Message{
Value: types.BigInt(sendPerRequest), Value: types.BigInt(h.sendPerRequest),
From: h.from, From: h.from,
To: to, To: to,
@ -340,7 +350,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
} }
smsg, err := h.api.MpoolPushMessage(h.ctx, &types.Message{ smsg, err := h.api.MpoolPushMessage(h.ctx, &types.Message{
Value: types.BigInt(sendPerRequest), Value: types.BigInt(h.sendPerRequest),
From: h.from, From: h.from,
To: owner, To: owner,