diff --git a/cmd/injectived/start.go b/cmd/injectived/start.go index c007c4f..09ccee1 100644 --- a/cmd/injectived/start.go +++ b/cmd/injectived/start.go @@ -60,6 +60,7 @@ import ( "github.com/InjectiveLabs/injective-core/cmd/injectived/config" + injwebsocket "github.com/InjectiveLabs/injective-core/injective-chain/websocket" "gopkg.in/DataDog/dd-trace-go.v1/profiler" ) @@ -267,6 +268,9 @@ func addStartNodeFlags(cmd *cobra.Command, opts server.StartCmdOptions) { cmd.Flags().Uint64(stream.FlagStreamServerPingInterval, 60, "Amount of time in seconds after which the server will send a keepalive ping to the client on an idle connection") cmd.Flags().Uint64(stream.FlagStreamServerPingResponseTimeout, 40, "Amount of time in seconds the server waits for the client to respond to a ping message before forcing a disconnection") + // add websocket server flag + cmd.Flags().String(injwebsocket.FlagWebsocketServer, "", "Configure websocket server listen addr") + // add store commit sync flag cmd.Flags().Bool(FlagMultiStoreCommitSync, false, "Define if commit multistore should use sync mode (false|true)") @@ -584,17 +588,38 @@ func startInProcess(svrCtx *server.Context, svrCfg serverconfig.Config, clientCt if pubBuffCap == 0 { return fmt.Errorf("invalid publisher buffer capacity %d. Please set a positive value greater than 0", pubBuffCap) } + + eventPublisherStarted := false injApp.EventPublisher.WithBufferCapacity(pubBuffCap) if chainStreamServeAddr != "" { // events are forwarded to StreamEvents channel in cosmos-sdk injApp.EnableStreamer = true if err = injApp.EventPublisher.Run(context.Background()); err != nil { svrCtx.Logger.Error("failed to start event publisher", "error", err) + } else { + eventPublisherStarted = true } if err = injApp.ChainStreamServer.Serve(chainStreamServeAddr); err != nil { svrCtx.Logger.Error("failed to start chainstream server", "error", err) } } + + websocketServerAddr := cast.ToString(svrCtx.Viper.Get(injwebsocket.FlagWebsocketServer)) + if websocketServerAddr != "" { + // don't start streamer server but still need part of its implement for websocket streams + injApp.EnableStreamer = true + if !eventPublisherStarted { + if err = injApp.EventPublisher.Run(context.Background()); err != nil { + svrCtx.Logger.Error("failed to start event publisher", "error", err) + } else { + eventPublisherStarted = true + } + } + + if err := injApp.WebsocketServer.Serve(websocketServerAddr); err != nil { + svrCtx.Logger.Error("failed to start websocket server", "error", err) + } + } } closer.Bind(func() { diff --git a/injective-chain/app/app.go b/injective-chain/app/app.go index 3b89d3e..0774e53 100644 --- a/injective-chain/app/app.go +++ b/injective-chain/app/app.go @@ -170,6 +170,7 @@ import ( wasmxtypes "github.com/InjectiveLabs/injective-core/injective-chain/modules/wasmx/types" "github.com/InjectiveLabs/injective-core/injective-chain/stream" chaintypes "github.com/InjectiveLabs/injective-core/injective-chain/types" + injwebsocket "github.com/InjectiveLabs/injective-core/injective-chain/websocket" // unnamed import of statik for swagger UI support _ "github.com/InjectiveLabs/injective-core/client/docs/statik" @@ -340,6 +341,7 @@ type InjectiveApp struct { // stream server ChainStreamServer *stream.StreamServer EventPublisher *stream.Publisher + WebsocketServer *injwebsocket.WebsocketServer } // NewInjectiveApp returns a reference to a new initialized Injective application. @@ -419,6 +421,7 @@ func NewInjectiveApp( bus := pubsub.NewServer() app.EventPublisher = stream.NewPublisher(app.StreamEvents, bus) app.ChainStreamServer = stream.NewChainStreamServer(bus, appOpts) + app.WebsocketServer = injwebsocket.NewWebsocketServer(app.ChainStreamServer, logger) authzcdc.GlobalCdc = codec.NewProtoCodec(app.interfaceRegistry) ante.GlobalCdc = codec.NewProtoCodec(app.interfaceRegistry) diff --git a/injective-chain/stream/stream_server.go b/injective-chain/stream/stream_server.go index 88f3023..055df89 100644 --- a/injective-chain/stream/stream_server.go +++ b/injective-chain/stream/stream_server.go @@ -182,9 +182,11 @@ func (s *StreamServer) Stream(req *types.StreamRequest, server types.Stream_Stre return status.Error(codes.Internal, err.Error()) } } - err = server.Send(outResp) - if err != nil { - return status.Error(codes.Internal, err.Error()) + if !req.OmitEmptyResponse || !isEmptyResponse(outResp) { + err = server.Send(outResp) + if err != nil { + return status.Error(codes.Internal, err.Error()) + } } height += 1 case <-server.Context().Done(): @@ -203,3 +205,16 @@ func (s *StreamServer) GetCurrentServerPort() int { } return s.listener.Addr().(*net.TCPAddr).Port } + +func isEmptyResponse(sr *types.StreamResponse) bool { + return len(sr.BankBalances) == 0 && + len(sr.SubaccountDeposits) == 0 && + len(sr.SpotTrades) == 0 && + len(sr.DerivativeTrades) == 0 && + len(sr.SpotOrders) == 0 && + len(sr.DerivativeOrders) == 0 && + len(sr.SpotOrderbookUpdates) == 0 && + len(sr.DerivativeOrderbookUpdates) == 0 && + len(sr.Positions) == 0 && + len(sr.OraclePrices) == 0 +} diff --git a/injective-chain/stream/types/query.pb.go b/injective-chain/stream/types/query.pb.go index cdbfe8a..8b75255 100644 --- a/injective-chain/stream/types/query.pb.go +++ b/injective-chain/stream/types/query.pb.go @@ -74,6 +74,7 @@ type StreamRequest struct { DerivativeOrderbooksFilter *OrderbookFilter `protobuf:"bytes,8,opt,name=derivative_orderbooks_filter,json=derivativeOrderbooksFilter,proto3" json:"derivative_orderbooks_filter,omitempty"` PositionsFilter *PositionsFilter `protobuf:"bytes,9,opt,name=positions_filter,json=positionsFilter,proto3" json:"positions_filter,omitempty"` OraclePriceFilter *OraclePriceFilter `protobuf:"bytes,10,opt,name=oracle_price_filter,json=oraclePriceFilter,proto3" json:"oracle_price_filter,omitempty"` + OmitEmptyResponse bool `protobuf:"varint,11,opt,name=omit_empty_response,json=omitEmptyResponse,proto3" json:"omit_empty_response,omitempty"` } func (m *StreamRequest) Reset() { *m = StreamRequest{} } @@ -179,6 +180,13 @@ func (m *StreamRequest) GetOraclePriceFilter() *OraclePriceFilter { return nil } +func (m *StreamRequest) GetOmitEmptyResponse() bool { + if m != nil { + return m.OmitEmptyResponse + } + return false +} + type StreamResponse struct { BlockHeight uint64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` BlockTime int64 `protobuf:"varint,2,opt,name=block_time,json=blockTime,proto3" json:"block_time,omitempty"` @@ -1521,110 +1529,112 @@ func init() { } var fileDescriptor_e23b7dcfb2fbc9c7 = []byte{ - // 1638 bytes of a gzipped FileDesc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78, 0x27, 0x87, 0xd6, 0xa0, 0x28, 0x49, 0x23, 0x97, 0xf8, 0x5d, 0x7b, 0x00, 0xea, 0x59, - 0x37, 0x6b, 0x13, 0x46, 0xa1, 0xdd, 0x82, 0xe5, 0x81, 0xdb, 0x86, 0x94, 0x98, 0xe7, 0xfb, 0x62, - 0x7e, 0xf3, 0x90, 0x19, 0x67, 0x1a, 0x15, 0xb4, 0x04, 0xa5, 0x67, 0x2e, 0xed, 0x62, 0x9b, 0xd4, - 0x09, 0x76, 0xca, 0x53, 0x08, 0xa0, 0x50, 0xf3, 0xbc, 0x16, 0x76, 0xca, 0x39, 0x54, 0x82, 0xb9, - 0x27, 0x66, 0x60, 0x37, 0xb1, 0x53, 0x9e, 0x46, 0x0b, 0xa0, 0xec, 0xb1, 0xd0, 0xda, 0x6d, 0xec, - 0x94, 0xf3, 0xbb, 0x0d, 0x28, 0x88, 0x9b, 0x0b, 0xf4, 0x22, 0x7e, 0xba, 0x31, 0xa2, 0xd5, 0x4b, - 0x5e, 0x7b, 0xae, 0x6d, 0x8d, 0x37, 0x14, 0xd7, 0x21, 0x3b, 0xb9, 0xda, 0xff, 0x5f, 0xbf, 0x5b, - 0xcf, 0xbd, 0x79, 0xb7, 0x9e, 0xfb, 0xf9, 0xdd, 0x7a, 0xee, 0xd5, 0xfb, 0xf5, 0xa9, 0x37, 0xef, - 0xd7, 0xa7, 0xbe, 0x7f, 0xbf, 0x3e, 0xf5, 0x7c, 0x3f, 0xf1, 0x85, 0x70, 0x10, 0xe1, 0x1d, 0x9a, - 0x16, 0xad, 0xc6, 0xe8, 0x77, 0x6c, 0xcf, 0xc7, 0xc9, 0xd7, 0xa6, 0x49, 0xdc, 0xe8, 0x1a, 0x99, - 0x7f, 0x43, 0x58, 0x05, 0x7e, 0x37, 0xfb, 0xd7, 0x5f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x42, - 0x1d, 0x82, 0x67, 0x16, 0x00, 0x00, + // 1666 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcd, 0x6e, 0xdb, 0xc6, + 0x16, 0x36, 0x2d, 0x5b, 0x16, 0x8f, 0xfc, 0x23, 0x8f, 0x1d, 0x83, 0x71, 0xee, 0xb5, 0x13, 0x3a, + 0xb9, 0xb1, 0xf3, 0x23, 0x39, 0xbe, 0x28, 0xd0, 0xa2, 0x8b, 0x24, 0xb2, 0x13, 0xc4, 0x81, 0x83, + 0x06, 0xb4, 0xd3, 0x02, 0x41, 0x53, 0x82, 0x22, 0x47, 0xd2, 0x54, 0x12, 0x29, 0x73, 0x48, 0x23, + 0x7a, 0x82, 0x76, 0x99, 0x6d, 0x97, 0xdd, 0x76, 0xd1, 0x47, 0xe8, 0xa2, 0xdd, 0x64, 0x55, 0x64, + 0x59, 0x14, 0x45, 0x5a, 0x24, 0x2f, 0x52, 0xcc, 0x0f, 0x29, 0x52, 0x92, 0x25, 0x39, 0x4d, 0x51, + 0x74, 0x25, 0xcd, 0xcc, 0x39, 0xdf, 0x37, 0x67, 0x66, 0xce, 0x37, 0x87, 0x03, 0x97, 0x89, 0xfb, + 0x25, 0xb6, 0x03, 0x72, 0x82, 0x4b, 0x34, 0xf0, 0xb1, 0xd5, 0x2a, 0x9d, 0xdc, 0xaa, 0xe0, 0xc0, + 0xba, 0x55, 0x3a, 0x0e, 0xb1, 0xdf, 0x29, 0xb6, 0x7d, 0x2f, 0xf0, 0x90, 0x16, 0x5b, 0x15, 0x85, + 0x55, 0x51, 0x5a, 0xad, 0xae, 0xd9, 0x1e, 0x6d, 0x79, 0xb4, 0x54, 0xb1, 0x28, 0x8e, 0x5d, 0x6d, + 0x8f, 0xb8, 0xc2, 0x73, 0x75, 0xb9, 0xe6, 0xd5, 0x3c, 0xfe, 0xb7, 0xc4, 0xfe, 0xc9, 0xde, 0xab, + 0x5d, 0x56, 0xfc, 0xdc, 0xae, 0x5b, 0x6e, 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57, 0xc6, 0x12, 0x1f, 0x63, 0x36, 0xa9, 0x37, 0xe8, 0x19, 0x2c, 0x0d, + 0x50, 0x1a, 0x6d, 0x8a, 0x23, 0xde, 0x38, 0x8b, 0xc4, 0x18, 0xa8, 0x5f, 0x56, 0xd0, 0x1e, 0xe4, + 0x13, 0x82, 0xa2, 0x4d, 0x73, 0xd8, 0x8d, 0x21, 0xb0, 0x91, 0x6a, 0x18, 0xd0, 0x15, 0x10, 0xf4, + 0x29, 0x2c, 0xf6, 0x49, 0x87, 0x96, 0xe5, 0x58, 0x43, 0x4e, 0xcd, 0x5e, 0x5a, 0x1f, 0x8c, 0x42, + 0xaf, 0x60, 0xa0, 0x87, 0x72, 0x76, 0x22, 0x91, 0xb5, 0x99, 0x51, 0x88, 0x87, 0x51, 0x12, 0x3d, + 0x69, 0x3b, 0x56, 0x20, 0xe7, 0x28, 0x12, 0x17, 0x7d, 0x9e, 0x9a, 0xa3, 0x44, 0xcc, 0x71, 0xc4, + 0xd2, 0x38, 0x73, 0x4c, 0xe2, 0x16, 0x7a, 0x65, 0x01, 0x99, 0xbd, 0x82, 0x60, 0x86, 0xdc, 0x94, + 0x6a, 0xea, 0xa8, 0x49, 0xc7, 0x29, 0x28, 0xc1, 0xd3, 0x52, 0x20, 0x3a, 0x29, 0x6a, 0x0c, 0x96, + 0x82, 0x98, 0x06, 0xce, 0x4a, 0x33, 0x48, 0x04, 0x22, 0xb2, 0x3b, 0xa0, 0xc6, 0xb9, 0xab, 0xe5, + 0x39, 0xb2, 0x3e, 0x3a, 0xfb, 0x8d, 0xae, 0x13, 0x4b, 0x81, 0x64, 0xaa, 0x53, 0x6d, 0x76, 0x54, + 0x0a, 0x24, 0x92, 0xdc, 0x98, 0x4d, 0x24, 0x36, 0xd5, 0xab, 0xb0, 0xd0, 0x33, 0x43, 0x54, 0x80, + 0x0c, 0xc5, 0xc7, 0x32, 0x35, 0xd9, 0x5f, 0x74, 0x17, 0xd4, 0x78, 0x51, 0xe4, 0x05, 0xbc, 0x31, + 0xc6, 0x62, 0x18, 0x5d, 0x2f, 0xfd, 0x7b, 0x05, 0xd4, 0x78, 0x00, 0x5d, 0x00, 0xb5, 0x65, 0xf9, + 0x0d, 0x1c, 0x98, 0xc4, 0xe1, 0x44, 0xaa, 0x91, 0x13, 0x1d, 0xfb, 0x0e, 0xba, 0x03, 0x50, 0x09, + 0x3b, 0x66, 0x13, 0x9f, 0xe0, 0x26, 0xd5, 0x26, 0x79, 0x6c, 0x97, 0x12, 0x74, 0x71, 0x99, 0x12, + 0x11, 0x1e, 0x30, 0x4b, 0x43, 0xad, 0x84, 0x1d, 0xfe, 0x8f, 0xa2, 0x32, 0xe4, 0x29, 0x6e, 0x36, + 0x23, 0x88, 0xcc, 0xb8, 0x10, 0xc0, 0xbc, 0x04, 0x86, 0xfe, 0x42, 0x81, 0x7c, 0x42, 0x39, 0x90, + 0x06, 0x33, 0x32, 0xbf, 0xe5, 0x84, 0xa3, 0x26, 0xaa, 0x41, 0x2e, 0x16, 0x23, 0x31, 0xdb, 0xf3, + 0x45, 0x51, 0xc4, 0x15, 0x59, 0x11, 0x17, 0x73, 0xec, 0x7a, 0xc4, 0x2d, 0x6f, 0xbf, 0x7c, 0xbd, + 0x3e, 0xf1, 0xdd, 0xef, 0xeb, 0x9b, 0x35, 0x12, 0xd4, 0xc3, 0x4a, 0xd1, 0xf6, 0x5a, 0x25, 0x59, + 0xf1, 0x89, 0x9f, 0x9b, 0xd4, 0x69, 0x94, 0x82, 0x4e, 0x1b, 0x53, 0xee, 0x40, 0x8d, 0x18, 0x5c, + 0xff, 0x5a, 0x01, 0xd4, 0x2f, 0x3d, 0x68, 0x03, 0xe6, 0x12, 0x2a, 0x16, 0x2f, 0xe8, 0x6c, 0xb7, + 0x73, 0xdf, 0x41, 0x8f, 0x20, 0x17, 0xeb, 0x9b, 0x98, 0xe4, 0xf5, 0x33, 0xe8, 0x1b, 0xbf, 0x13, + 0x26, 0x8c, 0x18, 0x42, 0x77, 0x61,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 0x54, 0xb2, + 0xfc, 0x2d, 0xf7, 0xff, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0x4b, 0xed, 0x3a, 0x49, 0x97, 0x16, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1754,6 +1764,16 @@ func (m *StreamRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.OmitEmptyResponse { + i-- + if m.OmitEmptyResponse { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x58 + } if m.OraclePriceFilter != nil { { size, err := m.OraclePriceFilter.MarshalToSizedBuffer(dAtA[:i]) @@ -3142,6 +3162,9 @@ func (m *StreamRequest) Size() (n int) { l = m.OraclePriceFilter.Size() n += 1 + l + sovQuery(uint64(l)) } + if m.OmitEmptyResponse { + n += 2 + } return n } @@ -4054,6 +4077,26 @@ func (m *StreamRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OmitEmptyResponse", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.OmitEmptyResponse = bool(v != 0) default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/injective-chain/websocket/websocket.go b/injective-chain/websocket/websocket.go new file mode 100644 index 0000000..2360eae --- /dev/null +++ b/injective-chain/websocket/websocket.go @@ -0,0 +1,201 @@ +package stream + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "net/http" + "sync" + + "cosmossdk.io/log" + + "github.com/InjectiveLabs/injective-core/injective-chain/stream" + "github.com/InjectiveLabs/injective-core/injective-chain/stream/types" + rpcserver "github.com/cometbft/cometbft/rpc/jsonrpc/server" + rpctypes "github.com/cometbft/cometbft/rpc/jsonrpc/types" + "google.golang.org/grpc" +) + +const ( + FlagWebsocketServer = "websocket-server" + + ResponseSuccess = "success" +) + +type WebsocketServer struct { + streamSvr *stream.StreamServer + manager *rpcserver.WebsocketManager + subscriptions map[string]map[string]*WsStream + mux *sync.RWMutex + logger log.Logger +} + +type WsStream struct { + ctx context.Context + id rpctypes.JSONRPCIntID + cancelFn func() + wsConn rpctypes.WSRPCConnection + grpc.ServerStream +} + +func NewWebsocketServer(streamSvr *stream.StreamServer, logger log.Logger) *WebsocketServer { + s := &WebsocketServer{ + streamSvr: streamSvr, + subscriptions: map[string]map[string]*WsStream{}, + mux: new(sync.RWMutex), + logger: logger, + } + fnMap := map[string]*rpcserver.RPCFunc{ + "subscribe": rpcserver.NewWSRPCFunc(s.subscribe, "q"), + "unsubscribe": rpcserver.NewWSRPCFunc(s.unsubscribe, "q"), + } + s.manager = rpcserver.NewWebsocketManager( + fnMap, + rpcserver.OnDisconnect(s.onDisconnect), + ) + return s +} + +func (ws *WsStream) Send(sr *types.StreamResponse) error { + return ws.wsConn.WriteRPCResponse(ws.ctx, rpctypes.NewRPCSuccessResponse(ws.id, *sr)) +} + +func (ws *WsStream) Context() context.Context { + return ws.ctx +} + +func (s *WebsocketServer) HasSubscriber(subscriber string) bool { + s.mux.RLock() + defer s.mux.RUnlock() + _, exist := s.subscriptions[subscriber] + return exist +} + +func (s *WebsocketServer) GetAllSubscriptions(subscriber string) (map[string]*WsStream, bool) { + s.mux.RLock() + defer s.mux.RUnlock() + subscriptions, exist := s.subscriptions[subscriber] + if !exist { + return nil, false + } + + return subscriptions, true +} + +func (s *WebsocketServer) GetSubscription(subscriber string, subscriptionHash []byte) (*WsStream, bool) { + s.mux.RLock() + defer s.mux.RUnlock() + subscriptions, exist := s.subscriptions[subscriber] + if !exist { + return nil, false + } + + ws, ok := subscriptions[string(subscriptionHash)] + return ws, ok +} + +func (s *WebsocketServer) SetSubscription(subscriber string, subscriptionHash []byte, ws *WsStream) { + s.mux.Lock() + defer s.mux.Unlock() + _, exist := s.subscriptions[subscriber] + if !exist { + s.subscriptions[subscriber] = map[string]*WsStream{} + } + + s.subscriptions[subscriber][string(subscriptionHash)] = ws +} + +func (s *WebsocketServer) DeleteSubscription(subscriber string, subscriptionHash []byte) { + s.mux.Lock() + defer s.mux.Unlock() + _, exist := s.subscriptions[subscriber] + if !exist { + return + } + + delete(s.subscriptions[subscriber], string(subscriptionHash)) +} + +func (s *WebsocketServer) DeleteSubscriber(subscriber string) { + s.mux.Lock() + defer s.mux.Unlock() + _, exist := s.subscriptions[subscriber] + if !exist { + return + } + + delete(s.subscriptions, subscriber) +} + +func (s *WebsocketServer) subscribe(ctx *rpctypes.Context, q *types.StreamRequest) (string, error) { + requestID, ok := ctx.JSONReq.ID.(rpctypes.JSONRPCIntID) + if !ok { + return "", fmt.Errorf("invalid request: expected non-negative int as id") + } + + subscriber := ctx.RemoteAddr() + bz, _ := json.Marshal(q) + rqHash := sha256.Sum256(bz) + cancelCtx, cancelFn := context.WithCancel(context.Background()) + if stream, exist := s.GetSubscription(subscriber, rqHash[:]); exist { + cancelFn() + return "", fmt.Errorf("request exists, id: %d", stream.id) + } + + ws := &WsStream{ + ctx: cancelCtx, + id: requestID, + cancelFn: cancelFn, + wsConn: ctx.WSConn, + } + s.SetSubscription(subscriber, rqHash[:], ws) + go func() { + if err := s.streamSvr.Stream(q, ws); err != nil { + ctx.WSConn.WriteRPCResponse(ws.ctx, rpctypes.NewRPCErrorResponse(requestID, 1, fmt.Sprintf("stream error: %s", err.Error()), "")) + return + } + }() + + return ResponseSuccess, nil +} + +func (s *WebsocketServer) unsubscribe(ctx *rpctypes.Context, q *types.StreamRequest) (string, error) { + _, ok := ctx.JSONReq.ID.(rpctypes.JSONRPCIntID) + if !ok { + return "", fmt.Errorf("invalid request: expected non-negative int as id") + } + subscriber := ctx.RemoteAddr() + bz, _ := json.Marshal(q) + rqHash := sha256.Sum256(bz) + ws, subscriptionExist := s.GetSubscription(subscriber, rqHash[:]) + if subscriptionExist { + ws.cancelFn() + s.DeleteSubscription(subscriber, rqHash[:]) + return ResponseSuccess, nil + } + return "", fmt.Errorf("subscription does not exist") +} + +func (s *WebsocketServer) onDisconnect(subscriber string) { + subscriptions, exist := s.GetAllSubscriptions(subscriber) + if !exist { + return + } + + for _, r := range subscriptions { + r.cancelFn() + } + s.DeleteSubscriber(subscriber) +} + +func (s *WebsocketServer) Serve(addr string) error { + http.HandleFunc("/ws", s.manager.WebsocketHandler) + go func() { + s.logger.Info("Websocket server started at " + addr) + if err := http.ListenAndServe(addr, nil); err != nil { + panic(err) + } + }() + return nil +} diff --git a/proto/injective/stream/v1beta1/query.proto b/proto/injective/stream/v1beta1/query.proto index 1803d57..752010b 100644 --- a/proto/injective/stream/v1beta1/query.proto +++ b/proto/injective/stream/v1beta1/query.proto @@ -24,6 +24,7 @@ message StreamRequest { [ (gogoproto.nullable) = true ]; PositionsFilter positions_filter = 9 [ (gogoproto.nullable) = true ]; OraclePriceFilter oracle_price_filter = 10 [ (gogoproto.nullable) = true ]; + bool omit_empty_response = 11; } message StreamResponse {