Client: DumpConsensusState, not DialSeeds. Cleanup
This commit is contained in:
parent
931af6a072
commit
98450ee2db
|
@ -39,6 +39,10 @@ func (c *HTTP) _assertIsClient() Client {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *HTTP) _assertIsNetworkClient() NetworkClient {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
func (c *HTTP) Status() (*ctypes.ResultStatus, error) {
|
func (c *HTTP) Status() (*ctypes.ResultStatus, error) {
|
||||||
tmResult := new(ctypes.TMResult)
|
tmResult := new(ctypes.TMResult)
|
||||||
_, err := c.rpc.Call("status", []interface{}{}, tmResult)
|
_, err := c.rpc.Call("status", []interface{}{}, tmResult)
|
||||||
|
@ -102,14 +106,13 @@ func (c *HTTP) NetInfo() (*ctypes.ResultNetInfo, error) {
|
||||||
return (*tmResult).(*ctypes.ResultNetInfo), nil
|
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)
|
tmResult := new(ctypes.TMResult)
|
||||||
// TODO: is this the correct way to marshall seeds?
|
_, err := c.rpc.Call("dump_consensus_state", nil, tmResult)
|
||||||
_, err := c.rpc.Call("dial_seeds", []interface{}{seeds}, tmResult)
|
|
||||||
if err != nil {
|
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) {
|
func (c *HTTP) BlockchainInfo(minHeight, maxHeight int) (*ctypes.ResultBlockchainInfo, error) {
|
||||||
|
|
|
@ -53,8 +53,7 @@ type SignClient interface {
|
||||||
// by concrete implementations.
|
// by concrete implementations.
|
||||||
type NetworkClient interface {
|
type NetworkClient interface {
|
||||||
NetInfo() (*ctypes.ResultNetInfo, error)
|
NetInfo() (*ctypes.ResultNetInfo, error)
|
||||||
// remove this???
|
DumpConsensusState() (*ctypes.ResultDumpConsensusState, error)
|
||||||
DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HistoryClient shows us data from genesis to now in large chunks.
|
// HistoryClient shows us data from genesis to now in large chunks.
|
||||||
|
|
|
@ -42,6 +42,10 @@ func (c Local) _assertIsClient() Client {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Local) _assertIsNetworkClient() NetworkClient {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
func (c Local) Status() (*ctypes.ResultStatus, error) {
|
func (c Local) Status() (*ctypes.ResultStatus, error) {
|
||||||
return core.Status()
|
return core.Status()
|
||||||
}
|
}
|
||||||
|
@ -70,6 +74,10 @@ func (c Local) NetInfo() (*ctypes.ResultNetInfo, error) {
|
||||||
return core.NetInfo()
|
return core.NetInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Local) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
|
||||||
|
return core.DumpConsensusState()
|
||||||
|
}
|
||||||
|
|
||||||
func (c Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
|
func (c Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
|
||||||
return core.UnsafeDialSeeds(seeds)
|
return core.UnsafeDialSeeds(seeds)
|
||||||
}
|
}
|
||||||
|
@ -93,46 +101,3 @@ func (c Local) Commit(height int) (*ctypes.ResultCommit, error) {
|
||||||
func (c Local) Validators() (*ctypes.ResultValidators, error) {
|
func (c Local) Validators() (*ctypes.ResultValidators, error) {
|
||||||
return core.Validators()
|
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")
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
|
@ -124,46 +124,3 @@ func (c Client) Commit(height int) (*ctypes.ResultCommit, error) {
|
||||||
func (c Client) Validators() (*ctypes.ResultValidators, error) {
|
func (c Client) Validators() (*ctypes.ResultValidators, error) {
|
||||||
return core.Validators()
|
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")
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
|
@ -67,13 +67,15 @@ func TestNetInfo(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDialSeeds(t *testing.T) {
|
func TestDumpConsensusState(t *testing.T) {
|
||||||
for i, c := range GetClients() {
|
for i, c := range GetClients() {
|
||||||
// FIXME: fix server so it doesn't panic on invalid input
|
// FIXME: fix server so it doesn't panic on invalid input
|
||||||
nc, ok := c.(client.NetworkClient)
|
nc, ok := c.(client.NetworkClient)
|
||||||
require.True(t, ok, "%d", i)
|
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)
|
require.Nil(t, err, "%d: %+v", i, err)
|
||||||
|
assert.NotEmpty(t, cons.RoundState)
|
||||||
|
assert.Empty(t, cons.PeerRoundStates)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue