Skip to content

Commit

Permalink
mod req global to upload
Browse files Browse the repository at this point in the history
  • Loading branch information
laocheng.cheng committed Dec 6, 2021
1 parent 1448f2d commit e93412d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cmd/btfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
nodeMount "github.com/TRON-US/go-btfs/fuse/node"
fsrepo "github.com/TRON-US/go-btfs/repo/fsrepo"
migrate "github.com/TRON-US/go-btfs/repo/fsrepo/migrations"
"github.com/TRON-US/go-btfs/settlement/swap/swapprotocol"
"github.com/TRON-US/go-btfs/spin"
"github.com/TRON-US/go-btfs/transaction"
"github.com/TRON-US/go-btfs/transaction/crypto"
Expand Down Expand Up @@ -236,8 +235,8 @@ func defaultMux(path string) corehttp.ServeOption {
}

func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) (_err error) {
swapprotocol.Req = req
swapprotocol.Env = env
//swapprotocol.Req = req
//swapprotocol.Env = env

cctx := env.(*oldcmds.Context)
_, b := os.LookupEnv(path.BtfsPathKey)
Expand Down
37 changes: 37 additions & 0 deletions core/commands/cheque/receive_total_count.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cheque

import (
"fmt"
"io"

cmds "github.com/TRON-US/go-btfs-cmds"
"github.com/TRON-US/go-btfs/chain"
)

type ReceiveTotalCountRet struct {
Count int `json:"count"`
}

var ReceiveChequesCountCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "send cheque(s) count",
},

Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
count, err := chain.SettleObject.ChequebookService.TotalIssuedCount()

if err != nil {
return err
}

return cmds.EmitOnce(res, &ReceiveTotalCountRet{Count: count})
},
Type: ReceiveTotalCountRet{},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, c *ReceiveTotalCountRet) error {
fmt.Println("receive cheque(s) count: ", c.Count)

return nil
}),
},
}
4 changes: 4 additions & 0 deletions core/commands/storage/upload/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/TRON-US/go-btfs/settlement/swap/swapprotocol"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -105,6 +106,9 @@ Use status command to check for completion:
},
RunTimeout: 15 * time.Minute,
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
swapprotocol.Req = req
swapprotocol.Env = env

ssId := uuid.New().String()
ctxParams, err := helper.ExtractContextParams(req, env)
if err != nil {
Expand Down

0 comments on commit e93412d

Please sign in to comment.