jsonrpc: remove test stuff from main code
This commit is contained in:
parent
98cbfdebb4
commit
64e3272fbf
@ -121,6 +121,4 @@ type API interface {
|
||||
|
||||
// Version provides information about API provider
|
||||
Version(context.Context) (Version, error)
|
||||
|
||||
TestCh(context.Context) (<-chan int, error)
|
||||
}
|
||||
|
@ -41,15 +41,9 @@ type Struct struct {
|
||||
NetPeers func(context.Context) ([]peer.AddrInfo, error)
|
||||
NetConnect func(context.Context, peer.AddrInfo) error
|
||||
NetAddrsListen func(context.Context) (peer.AddrInfo, error)
|
||||
|
||||
TestCh func(context.Context) (<-chan int, error)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Struct) TestCh(ctx context.Context) (<-chan int, error) {
|
||||
return c.Internal.TestCh(ctx)
|
||||
}
|
||||
|
||||
func (c *Struct) ClientListImports(ctx context.Context) ([]Import, error) {
|
||||
return c.Internal.ClientListImports(ctx)
|
||||
}
|
||||
|
26
cli/cmd.go
26
cli/cmd.go
@ -2,7 +2,6 @@ package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
@ -68,29 +67,4 @@ var Commands = []*cli.Command{
|
||||
versionCmd,
|
||||
walletCmd,
|
||||
createMinerCmd,
|
||||
|
||||
{
|
||||
Name: "testch",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, err := getAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx := reqContext(cctx)
|
||||
|
||||
c, err := api.TestCh(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case n := <-c:
|
||||
fmt.Println(n)
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -322,6 +322,7 @@ func TestChan(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
|
||||
|
||||
sub, err := client.Sub(ctx, 2)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
22
node/api.go
22
node/api.go
@ -2,8 +2,6 @@ package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/api"
|
||||
"github.com/filecoin-project/go-lotus/build"
|
||||
@ -30,26 +28,6 @@ type API struct {
|
||||
Wallet *chain.Wallet
|
||||
}
|
||||
|
||||
func (a *API) TestCh(ctx context.Context) (<-chan int, error) {
|
||||
out := make(chan int)
|
||||
go func() {
|
||||
defer close(out)
|
||||
var n int
|
||||
for {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
n++
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
fmt.Println("CTXCANCEL!")
|
||||
return
|
||||
case out <- n:
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *API) ChainSubmitBlock(ctx context.Context, blk *chain.BlockMsg) error {
|
||||
if err := a.Chain.AddBlock(blk.Header); err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user