diff --git a/baseapp/abci.go b/baseapp/abci.go index 965969918fd9..c9b68302839a 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -819,28 +819,32 @@ func handleQueryStore(app *BaseApp, path []string, req abci.RequestQuery) abci.R func handleQueryP2P(app *BaseApp, path []string) abci.ResponseQuery { // "/p2p" prefix for p2p queries - if len(path) >= 4 { - cmd, typ, arg := path[1], path[2], path[3] - switch cmd { - case "filter": - switch typ { - case "addr": - return app.FilterPeerByAddrPort(arg) - - case "id": - return app.FilterPeerByID(arg) - } + if len(path) < 4 { + return sdkerrors.QueryResult( + sdkerrors.Wrap( + sdkerrors.ErrUnknownRequest, "path should be p2p filter ", + ), + ) + } - default: - return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "expected second parameter to be 'filter'")) + var resp abci.ResponseQuery + + cmd, typ, arg := path[1], path[2], path[3] + switch cmd { + case "filter": + switch typ { + case "addr": + resp = app.FilterPeerByAddrPort(arg) + + case "id": + resp = app.FilterPeerByID(arg) } + + default: + resp = sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "expected second parameter to be 'filter'")) } - return sdkerrors.QueryResult( - sdkerrors.Wrap( - sdkerrors.ErrUnknownRequest, "expected path is p2p filter ", - ), - ) + return resp } func handleQueryCustom(app *BaseApp, path []string, req abci.RequestQuery) abci.ResponseQuery {