jsonrpc: gofmt
This commit is contained in:
parent
790ed0730e
commit
fd40f9a82a
@ -70,7 +70,7 @@ var Commands = []*cli.Command{
|
||||
createMinerCmd,
|
||||
|
||||
{
|
||||
Name:"testch",
|
||||
Name: "testch",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := getAPI(cctx)
|
||||
if err != nil {
|
||||
@ -87,7 +87,7 @@ var Commands = []*cli.Command{
|
||||
select {
|
||||
case n := <-c:
|
||||
fmt.Println(n)
|
||||
case <- ctx.Done():
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ package daemon
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
"gopkg.in/urfave/cli.v2"
|
||||
|
||||
|
@ -34,7 +34,6 @@ func (e *ErrClient) Unwrap(err error) error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
|
||||
type clientResponse struct {
|
||||
Jsonrpc string `json:"jsonrpc"`
|
||||
Result json.RawMessage `json:"result"`
|
||||
|
@ -98,7 +98,10 @@ func handleWsConn(ctx context.Context, conn *websocket.Conn, handler handlers, r
|
||||
|
||||
var chOnce sync.Once
|
||||
var outId uint64
|
||||
type chReg struct { id uint64; ch reflect.Value }
|
||||
type chReg struct {
|
||||
id uint64
|
||||
ch reflect.Value
|
||||
}
|
||||
registerCh := make(chan chReg)
|
||||
defer close(registerCh)
|
||||
|
||||
@ -113,7 +116,6 @@ func handleWsConn(ctx context.Context, conn *websocket.Conn, handler handlers, r
|
||||
}
|
||||
var caseToId []uint64
|
||||
|
||||
|
||||
for {
|
||||
chosen, val, ok := reflect.Select(cases)
|
||||
|
||||
@ -136,12 +138,11 @@ func handleWsConn(ctx context.Context, conn *websocket.Conn, handler handlers, r
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
if !ok {
|
||||
n := len(caseToId)
|
||||
if n > 0 {
|
||||
cases[chosen] = cases[n]
|
||||
caseToId[chosen - 1] = caseToId[n - 1]
|
||||
caseToId[chosen-1] = caseToId[n-1]
|
||||
}
|
||||
|
||||
cases = cases[:n]
|
||||
@ -153,7 +154,7 @@ func handleWsConn(ctx context.Context, conn *websocket.Conn, handler handlers, r
|
||||
Jsonrpc: "2.0",
|
||||
ID: nil, // notification
|
||||
Method: chValue,
|
||||
Params: []param{{v: reflect.ValueOf(caseToId[chosen - 1])}, {v: val}},
|
||||
Params: []param{{v: reflect.ValueOf(caseToId[chosen-1])}, {v: val}},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user