use of org.aion.api.server.types.ArgFltr in project aion by aionnetwork.
the class ApiWeb3Aion method eth_newFilter.
public RpcMsg eth_newFilter(Object _params) {
if (!isFilterEnabled) {
return new RpcMsg(null, RpcError.NOT_ALLOWED, "Filters over rpc disabled.");
}
JSONObject _filterObj;
if (_params instanceof JSONArray) {
_filterObj = ((JSONArray) _params).getJSONObject(0);
} else if (_params instanceof JSONObject) {
_filterObj = ((JSONObject) _params).getJSONObject("filter");
} else {
return new RpcMsg(null, RpcError.INVALID_PARAMS, "Invalid parameters");
}
ArgFltr rf = ArgFltr.fromJSON(_filterObj);
if (rf == null) {
return new RpcMsg(null, RpcError.INVALID_PARAMS, "Invalid filter object provided.");
}
FltrLg filter = createFilter(rf);
if (filter.getFilterError() != null) {
return new RpcMsg(null, RpcError.INVALID_PARAMS, "Invalid filter object provided. " + filter.getFilterError());
}
// "install" the filter after populating historical data;
// rationale: until the user gets the id back, the user should not expect the filter to be
// "installed" anyway.
long id = fltrIndex.getAndIncrement();
installedFilters.put(id, filter);
return new RpcMsg(StringUtils.toJsonHex(id));
}
use of org.aion.api.server.types.ArgFltr in project aion by aionnetwork.
the class ApiWeb3Aion method eth_getLogs.
public RpcMsg eth_getLogs(Object _params) {
JSONObject _filterObj;
if (_params instanceof JSONArray) {
_filterObj = ((JSONArray) _params).getJSONObject(0);
} else if (_params instanceof JSONObject) {
_filterObj = ((JSONObject) _params).getJSONObject("filter");
} else {
return new RpcMsg(null, RpcError.INVALID_PARAMS, "Invalid parameters");
}
ArgFltr rf = ArgFltr.fromJSON(_filterObj);
if (rf == null) {
return new RpcMsg(null, RpcError.INVALID_PARAMS, "Invalid filter object provided.");
}
FltrLg filter = createFilter(rf);
if (filter.getFilterError() != null) {
return new RpcMsg(null, RpcError.INVALID_PARAMS, "Invalid filter object provided. " + filter.getFilterError());
}
return new RpcMsg(buildFilterResponse(filter));
}
Aggregations