diff --git a/rpc/client/httpclient.go b/rpc/client/httpclient.go index ea81199fc..6245333c5 100644 --- a/rpc/client/httpclient.go +++ b/rpc/client/httpclient.go @@ -39,6 +39,10 @@ func (c *HTTP) _assertIsClient() Client { return c } +func (c *HTTP) _assertIsNetworkClient() NetworkClient { + return c +} + func (c *HTTP) Status() (*ctypes.ResultStatus, error) { tmResult := new(ctypes.TMResult) _, err := c.rpc.Call("status", []interface{}{}, tmResult) @@ -102,14 +106,13 @@ func (c *HTTP) NetInfo() (*ctypes.ResultNetInfo, error) { return (*tmResult).(*ctypes.ResultNetInfo), nil } -func (c *HTTP) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { +func (c *HTTP) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) { tmResult := new(ctypes.TMResult) - // TODO: is this the correct way to marshall seeds? - _, err := c.rpc.Call("dial_seeds", []interface{}{seeds}, tmResult) + _, err := c.rpc.Call("dump_consensus_state", nil, tmResult) if err != nil { - return nil, errors.Wrap(err, "DialSeeds") + return nil, errors.Wrap(err, "DumpConsensusState") } - return (*tmResult).(*ctypes.ResultDialSeeds), nil + return (*tmResult).(*ctypes.ResultDumpConsensusState), nil } func (c *HTTP) BlockchainInfo(minHeight, maxHeight int) (*ctypes.ResultBlockchainInfo, error) { diff --git a/rpc/client/interface.go b/rpc/client/interface.go index b50950e45..5dffe30bc 100644 --- a/rpc/client/interface.go +++ b/rpc/client/interface.go @@ -53,8 +53,7 @@ type SignClient interface { // by concrete implementations. type NetworkClient interface { NetInfo() (*ctypes.ResultNetInfo, error) - // remove this??? - DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) + DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) } // HistoryClient shows us data from genesis to now in large chunks. diff --git a/rpc/client/localclient.go b/rpc/client/localclient.go index eb180a6e2..fc533f15f 100644 --- a/rpc/client/localclient.go +++ b/rpc/client/localclient.go @@ -42,6 +42,10 @@ func (c Local) _assertIsClient() Client { return c } +func (c Local) _assertIsNetworkClient() NetworkClient { + return c +} + func (c Local) Status() (*ctypes.ResultStatus, error) { return core.Status() } @@ -70,6 +74,10 @@ func (c Local) NetInfo() (*ctypes.ResultNetInfo, error) { return core.NetInfo() } +func (c Local) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) { + return core.DumpConsensusState() +} + func (c Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { return core.UnsafeDialSeeds(seeds) } @@ -93,46 +101,3 @@ func (c Local) Commit(height int) (*ctypes.ResultCommit, error) { func (c Local) Validators() (*ctypes.ResultValidators, error) { return core.Validators() } - -/** websocket event stuff here... **/ - -/* -// StartWebsocket starts up a websocket and a listener goroutine -// if already started, do nothing -func (c Client) StartWebsocket() error { - var err error - if c.ws == nil { - ws := rpcclient.NewWSClient(c.remote, c.endpoint) - _, err = ws.Start() - if err == nil { - c.ws = ws - } - } - return errors.Wrap(err, "StartWebsocket") -} - -// StopWebsocket stops the websocket connection -func (c Client) StopWebsocket() { - if c.ws != nil { - c.ws.Stop() - c.ws = nil - } -} - -// GetEventChannels returns the results and error channel from the websocket -func (c Client) GetEventChannels() (chan json.RawMessage, chan error) { - if c.ws == nil { - return nil, nil - } - return c.ws.ResultsCh, c.ws.ErrorsCh -} - -func (c Client) Subscribe(event string) error { - return errors.Wrap(c.ws.Subscribe(event), "Subscribe") -} - -func (c Client) Unsubscribe(event string) error { - return errors.Wrap(c.ws.Unsubscribe(event), "Unsubscribe") -} - -*/ diff --git a/rpc/client/mock/client.go b/rpc/client/mock/client.go index ddeb1219f..0dcba718c 100644 --- a/rpc/client/mock/client.go +++ b/rpc/client/mock/client.go @@ -124,46 +124,3 @@ func (c Client) Commit(height int) (*ctypes.ResultCommit, error) { func (c Client) Validators() (*ctypes.ResultValidators, error) { return core.Validators() } - -/** websocket event stuff here... **/ - -/* -// StartWebsocket starts up a websocket and a listener goroutine -// if already started, do nothing -func (c Client) StartWebsocket() error { - var err error - if c.ws == nil { - ws := rpcclient.NewWSClient(c.remote, c.endpoint) - _, err = ws.Start() - if err == nil { - c.ws = ws - } - } - return errors.Wrap(err, "StartWebsocket") -} - -// StopWebsocket stops the websocket connection -func (c Client) StopWebsocket() { - if c.ws != nil { - c.ws.Stop() - c.ws = nil - } -} - -// GetEventChannels returns the results and error channel from the websocket -func (c Client) GetEventChannels() (chan json.RawMessage, chan error) { - if c.ws == nil { - return nil, nil - } - return c.ws.ResultsCh, c.ws.ErrorsCh -} - -func (c Client) Subscribe(event string) error { - return errors.Wrap(c.ws.Subscribe(event), "Subscribe") -} - -func (c Client) Unsubscribe(event string) error { - return errors.Wrap(c.ws.Unsubscribe(event), "Unsubscribe") -} - -*/ diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index f37386c37..d96708142 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -67,13 +67,15 @@ func TestNetInfo(t *testing.T) { } } -func TestDialSeeds(t *testing.T) { +func TestDumpConsensusState(t *testing.T) { for i, c := range GetClients() { // FIXME: fix server so it doesn't panic on invalid input nc, ok := c.(client.NetworkClient) require.True(t, ok, "%d", i) - _, err := nc.DialSeeds([]string{"12.34.56.78:12345"}) + cons, err := nc.DumpConsensusState() require.Nil(t, err, "%d: %+v", i, err) + assert.NotEmpty(t, cons.RoundState) + assert.Empty(t, cons.PeerRoundStates) } }