Filtering for eth_getLogs (#120)

* Filtered logs based param criteria
* addded PublicFilterAPI
* added filter logs func to filter based on params
* added Unmarshal func from go-ethereum

* Linted

* made requested changes
This commit is contained in:
Dustin Brickwood
2019-10-07 22:32:28 -05:00
committed by GitHub
parent eab81bc578
commit a61f3b892d
5 changed files with 184 additions and 1 deletions
+13
View File
@@ -24,6 +24,7 @@ const (
QueryHashToHeight = "hashToHeight"
QueryTxLogs = "txLogs"
QueryLogsBloom = "logsBloom"
QueryLogs = "logs"
)
// NewQuerier is the module level router for state queries
@@ -48,6 +49,8 @@ func NewQuerier(keeper Keeper) sdk.Querier {
return queryTxLogs(ctx, path, keeper)
case QueryLogsBloom:
return queryBlockLogsBloom(ctx, path, keeper)
case QueryLogs:
return queryLogs(ctx, path, keeper)
default:
return nil, sdk.ErrUnknownRequest("unknown query endpoint")
}
@@ -167,3 +170,13 @@ func queryTxLogs(ctx sdk.Context, path []string, keeper Keeper) ([]byte, sdk.Err
return res, nil
}
func queryLogs(ctx sdk.Context, path []string, keeper Keeper) ([]byte, sdk.Error) {
logs := keeper.Logs(ctx)
l, err := codec.MarshalJSONIndent(keeper.cdc, logs)
if err != nil {
panic("could not marshal result to JSON: " + err.Error())
}
return l, nil
}