Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement removing from filter by ws #570

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions jsonrpc/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func (d *Dispatcher) getFnHandler(req Request) (*serviceData, *funcData, Error)

type wsConn interface {
WriteMessage(messageType int, data []byte) error
GetFilterID() string
SetFilterID(string)
}

// as per https://www.jsonrpc.org/specification, the `id` in JSON-RPC 2.0
Expand Down Expand Up @@ -169,6 +171,10 @@ func (d *Dispatcher) handleUnsubscribe(req Request) (bool, Error) {
return d.filterManager.Uninstall(filterID), nil
}

func (d *Dispatcher) RemoveFilterByWs(conn wsConn) {
d.filterManager.RemoveFilterByWs(conn)
}

func (d *Dispatcher) HandleWs(reqBody []byte, conn wsConn) ([]byte, error) {
var req Request
if err := json.Unmarshal(reqBody, &req); err != nil {
Expand Down
8 changes: 2 additions & 6 deletions jsonrpc/eth_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,16 +809,12 @@ func (e *Eth) GetFilterChanges(id string) (interface{}, error) {

// UninstallFilter uninstalls a filter with given ID
func (e *Eth) UninstallFilter(id string) (bool, error) {
ok := e.filterManager.Uninstall(id)

return ok, nil
return e.filterManager.Uninstall(id), nil
}

// Unsubscribe uninstalls a filter in a websocket
func (e *Eth) Unsubscribe(id string) (bool, error) {
ok := e.filterManager.Uninstall(id)

return ok, nil
return e.filterManager.Uninstall(id), nil
}

func (e *Eth) getBlockHeader(number BlockNumber) (*types.Header, error) {
Expand Down
Loading