mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-13 21:31:23 +00:00
move ResultEvent to go-events
This commit is contained in:
@ -188,7 +188,8 @@ func (n *Node) StartRPC() (net.Listener, error) {
|
||||
// conflicts with their own rpc
|
||||
wire.RegisterInterface(
|
||||
struct{ rpctypes.Result }{},
|
||||
wire.ConcreteType{&ctypes.TendermintResult{}, 0x1},
|
||||
wire.ConcreteType{&events.EventResult{}, 0x1},
|
||||
wire.ConcreteType{&ctypes.TendermintResult{}, 0x2},
|
||||
)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
@ -11,7 +11,7 @@ func Subscribe(wsCtx rpctypes.WSRPCContext, event string) (*ctypes.ResultSubscri
|
||||
wsCtx.GetEventSwitch().AddListenerForEvent(wsCtx.GetRemoteAddr(), event, func(msg events.EventData) {
|
||||
// NOTE: EventSwitch callbacks must be nonblocking
|
||||
// NOTE: RPCResponses of subscribed events have id suffix "#event"
|
||||
wsCtx.TryWriteRPCResponse(rpctypes.NewRPCResponse(wsCtx.Request.ID+"#event", &ctypes.TendermintResult{&ctypes.ResultEvent{event, msg}}, ""))
|
||||
wsCtx.TryWriteRPCResponse(rpctypes.NewRPCResponse(wsCtx.Request.ID+"#event", &events.EventResult{event, msg}, ""))
|
||||
})
|
||||
return &ctypes.ResultSubscribe{}, nil
|
||||
}
|
||||
@ -21,7 +21,7 @@ func Unsubscribe(wsCtx rpctypes.WSRPCContext, event string) (*ctypes.ResultUnsub
|
||||
wsCtx.GetEventSwitch().AddListenerForEvent(wsCtx.GetRemoteAddr(), event, func(msg events.EventData) {
|
||||
// NOTE: EventSwitch callbacks must be nonblocking
|
||||
// NOTE: RPCResponses of subscribed events have id suffix "#event"
|
||||
wsCtx.TryWriteRPCResponse(rpctypes.NewRPCResponse(wsCtx.Request.ID+"#event", &ctypes.TendermintResult{&ctypes.ResultEvent{event, msg}}, ""))
|
||||
wsCtx.TryWriteRPCResponse(rpctypes.NewRPCResponse(wsCtx.Request.ID+"#event", &events.EventResult{event, msg}, ""))
|
||||
})
|
||||
return &ctypes.ResultUnsubscribe{}, nil
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package core_types
|
||||
|
||||
import (
|
||||
"github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/go-events"
|
||||
"github.com/tendermint/go-p2p"
|
||||
"github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
@ -67,12 +66,6 @@ type ResultSubscribe struct {
|
||||
type ResultUnsubscribe struct {
|
||||
}
|
||||
|
||||
// TODO: something about this
|
||||
type ResultEvent struct {
|
||||
Event string `json:"event"`
|
||||
Data events.EventData `json:"data"`
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// response & result types
|
||||
|
||||
@ -88,7 +81,6 @@ const (
|
||||
ResultTypeListUnconfirmedTxs = byte(0x09)
|
||||
ResultTypeSubscribe = byte(0x0A)
|
||||
ResultTypeUnsubscribe = byte(0x0B)
|
||||
ResultTypeEvent = byte(0x0C)
|
||||
)
|
||||
|
||||
type TendermintResultInterface interface{}
|
||||
@ -112,5 +104,4 @@ var _ = wire.RegisterInterface(
|
||||
wire.ConcreteType{&ResultListUnconfirmedTxs{}, ResultTypeListUnconfirmedTxs},
|
||||
wire.ConcreteType{&ResultSubscribe{}, ResultTypeSubscribe},
|
||||
wire.ConcreteType{&ResultUnsubscribe{}, ResultTypeUnsubscribe},
|
||||
wire.ConcreteType{&ResultEvent{}, ResultTypeEvent},
|
||||
)
|
||||
|
@ -11,11 +11,11 @@ import (
|
||||
"github.com/tendermint/go-p2p"
|
||||
"github.com/tendermint/go-wire"
|
||||
|
||||
"github.com/tendermint/go-events"
|
||||
client "github.com/tendermint/go-rpc/client"
|
||||
"github.com/tendermint/go-rpc/types"
|
||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
||||
nm "github.com/tendermint/tendermint/node"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
@ -137,7 +137,7 @@ func waitForEvent(t *testing.T, con *websocket.Conn, eventid string, dieOnTimeou
|
||||
errCh <- err
|
||||
break
|
||||
}
|
||||
event, ok := response.Result.(*ctypes.TendermintResult).Result.(*ctypes.ResultEvent)
|
||||
event, ok := response.Result.(*events.EventResult)
|
||||
if ok && event.Event == eventid {
|
||||
goodCh <- p
|
||||
break
|
||||
@ -191,7 +191,7 @@ func unmarshalResponseNewBlock(b []byte) (*types.Block, error) {
|
||||
if response.Error != "" {
|
||||
return nil, fmt.Errorf(response.Error)
|
||||
}
|
||||
block := response.Result.(*ctypes.TendermintResult).Result.(*ctypes.ResultEvent).Data.(types.EventDataNewBlock).Block
|
||||
block := response.Result.(*events.EventResult).Data.(types.EventDataNewBlock).Block
|
||||
return block, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user