|
13 | 13 | */
|
14 | 14 | package org.fisco.bcos.sdk.v3.client;
|
15 | 15 |
|
| 16 | +import static org.fisco.bcos.sdk.v3.utils.ObjectMapperFactory.getObjectMapper; |
| 17 | + |
16 | 18 | import com.fasterxml.jackson.core.JsonProcessingException;
|
17 | 19 | import com.fasterxml.jackson.databind.ObjectMapper;
|
18 | 20 | import java.math.BigInteger;
|
|
43 | 45 | import org.fisco.bcos.sdk.v3.client.protocol.response.Call;
|
44 | 46 | import org.fisco.bcos.sdk.v3.client.protocol.response.Code;
|
45 | 47 | import org.fisco.bcos.sdk.v3.client.protocol.response.ConsensusStatus;
|
| 48 | +import org.fisco.bcos.sdk.v3.client.protocol.response.EthFilter; |
| 49 | +import org.fisco.bcos.sdk.v3.client.protocol.response.EthLog; |
| 50 | +import org.fisco.bcos.sdk.v3.client.protocol.response.EthUninstallFilter; |
46 | 51 | import org.fisco.bcos.sdk.v3.client.protocol.response.GroupPeers;
|
47 | 52 | import org.fisco.bcos.sdk.v3.client.protocol.response.ObserverList;
|
48 | 53 | import org.fisco.bcos.sdk.v3.client.protocol.response.PbftView;
|
|
63 | 68 | import org.fisco.bcos.sdk.v3.model.callback.ResponseCallback;
|
64 | 69 | import org.fisco.bcos.sdk.v3.model.callback.TransactionCallback;
|
65 | 70 | import org.fisco.bcos.sdk.v3.utils.Hex;
|
66 |
| -import org.fisco.bcos.sdk.v3.utils.ObjectMapperFactory; |
67 | 71 | import org.slf4j.Logger;
|
68 | 72 | import org.slf4j.LoggerFactory;
|
69 | 73 |
|
@@ -94,7 +98,7 @@ public class ClientImpl implements Client {
|
94 | 98 | private CryptoSuite cryptoSuite;
|
95 | 99 | private RpcJniObj rpcJniObj;
|
96 | 100 |
|
97 |
| - protected final ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper(); |
| 101 | + protected final ObjectMapper objectMapper = getObjectMapper(); |
98 | 102 |
|
99 | 103 | protected void initGroupInfo() {
|
100 | 104 | this.groupInfo = getGroupInfo().getResult();
|
@@ -1306,13 +1310,166 @@ public String getNodeToSendRequest() {
|
1306 | 1310 | * with max and min version bits combined, which is (max|min). Max protocol version is in first
|
1307 | 1311 | * 16 bit, and min protocol version in the second 16 bit.
|
1308 | 1312 | *
|
1309 |
| - * @return (max|min) bits combined. |
| 1313 | + * @return (max | min) bits combined. |
1310 | 1314 | */
|
1311 | 1315 | @Override
|
1312 | 1316 | public int getNegotiatedProtocol() {
|
1313 | 1317 | return negotiatedProtocol;
|
1314 | 1318 | }
|
1315 | 1319 |
|
| 1320 | + @Override |
| 1321 | + public EthFilter newFilter(org.fisco.bcos.sdk.v3.client.protocol.request.EthFilter params) { |
| 1322 | + return this.callRemoteMethod( |
| 1323 | + this.groupID, |
| 1324 | + "", |
| 1325 | + new JsonRpcRequest<>( |
| 1326 | + JsonRpcMethods.NEW_FILTER, Arrays.asList(this.groupID, params)), |
| 1327 | + EthFilter.class); |
| 1328 | + } |
| 1329 | + |
| 1330 | + @Override |
| 1331 | + public void newFilterAsync( |
| 1332 | + org.fisco.bcos.sdk.v3.client.protocol.request.EthFilter params, |
| 1333 | + RespCallback<EthFilter> callback) { |
| 1334 | + this.asyncCallRemoteMethod( |
| 1335 | + this.groupID, |
| 1336 | + "", |
| 1337 | + new JsonRpcRequest<>(JsonRpcMethods.NEW_FILTER, Arrays.asList(groupID, params)), |
| 1338 | + EthFilter.class, |
| 1339 | + callback); |
| 1340 | + } |
| 1341 | + |
| 1342 | + @Override |
| 1343 | + public EthFilter newBlockFilter() { |
| 1344 | + return this.callRemoteMethod( |
| 1345 | + this.groupID, |
| 1346 | + "", |
| 1347 | + new JsonRpcRequest<>(JsonRpcMethods.NEW_BLOCK_FILTER, Arrays.asList(this.groupID)), |
| 1348 | + EthFilter.class); |
| 1349 | + } |
| 1350 | + |
| 1351 | + @Override |
| 1352 | + public void newBlockFilterAsync(RespCallback<EthFilter> callback) { |
| 1353 | + this.asyncCallRemoteMethod( |
| 1354 | + this.groupID, |
| 1355 | + "", |
| 1356 | + new JsonRpcRequest<>(JsonRpcMethods.NEW_BLOCK_FILTER, Arrays.asList(this.groupID)), |
| 1357 | + EthFilter.class, |
| 1358 | + callback); |
| 1359 | + } |
| 1360 | + |
| 1361 | + @Override |
| 1362 | + public EthFilter newPendingTransactionFilter() { |
| 1363 | + return this.callRemoteMethod( |
| 1364 | + this.groupID, |
| 1365 | + "", |
| 1366 | + new JsonRpcRequest<>( |
| 1367 | + JsonRpcMethods.NEW_PENDING_TX_FILTER, Arrays.asList(this.groupID)), |
| 1368 | + EthFilter.class); |
| 1369 | + } |
| 1370 | + |
| 1371 | + @Override |
| 1372 | + public void newPendingTransactionFilterAsync(RespCallback<EthFilter> callback) { |
| 1373 | + this.asyncCallRemoteMethod( |
| 1374 | + this.groupID, |
| 1375 | + "", |
| 1376 | + new JsonRpcRequest<>( |
| 1377 | + JsonRpcMethods.NEW_PENDING_TX_FILTER, Arrays.asList(this.groupID)), |
| 1378 | + EthFilter.class, |
| 1379 | + callback); |
| 1380 | + } |
| 1381 | + |
| 1382 | + @Override |
| 1383 | + public EthLog getFilterChanges(EthFilter filter) { |
| 1384 | + return this.callRemoteMethod( |
| 1385 | + this.groupID, |
| 1386 | + "", |
| 1387 | + new JsonRpcRequest<>( |
| 1388 | + JsonRpcMethods.GET_FILTER_CHANGES, |
| 1389 | + Arrays.asList(this.groupID, filter.getResult())), |
| 1390 | + EthLog.class); |
| 1391 | + } |
| 1392 | + |
| 1393 | + @Override |
| 1394 | + public void getFilterChangesAsync(EthFilter filter, RespCallback<EthLog> callback) { |
| 1395 | + this.asyncCallRemoteMethod( |
| 1396 | + this.groupID, |
| 1397 | + "", |
| 1398 | + new JsonRpcRequest<>( |
| 1399 | + JsonRpcMethods.GET_FILTER_CHANGES, |
| 1400 | + Arrays.asList(this.groupID, filter.getResult())), |
| 1401 | + EthLog.class, |
| 1402 | + callback); |
| 1403 | + } |
| 1404 | + |
| 1405 | + @Override |
| 1406 | + public EthUninstallFilter uninstallFilter(EthFilter filter) { |
| 1407 | + return this.callRemoteMethod( |
| 1408 | + this.groupID, |
| 1409 | + "", |
| 1410 | + new JsonRpcRequest<>( |
| 1411 | + JsonRpcMethods.UNINSTALL_FILTER, |
| 1412 | + Arrays.asList(this.groupID, filter.getResult())), |
| 1413 | + EthUninstallFilter.class); |
| 1414 | + } |
| 1415 | + |
| 1416 | + @Override |
| 1417 | + public void uninstallFilterAsync(EthFilter filter, RespCallback<EthUninstallFilter> callback) { |
| 1418 | + this.asyncCallRemoteMethod( |
| 1419 | + this.groupID, |
| 1420 | + "", |
| 1421 | + new JsonRpcRequest<>( |
| 1422 | + JsonRpcMethods.UNINSTALL_FILTER, |
| 1423 | + Arrays.asList(this.groupID, filter.getResult())), |
| 1424 | + EthUninstallFilter.class, |
| 1425 | + callback); |
| 1426 | + } |
| 1427 | + |
| 1428 | + @Override |
| 1429 | + public EthLog getLogs(org.fisco.bcos.sdk.v3.client.protocol.request.EthFilter params) { |
| 1430 | + return this.callRemoteMethod( |
| 1431 | + this.groupID, |
| 1432 | + "", |
| 1433 | + new JsonRpcRequest<>(JsonRpcMethods.GET_LOGS, Arrays.asList(this.groupID, params)), |
| 1434 | + EthLog.class); |
| 1435 | + } |
| 1436 | + |
| 1437 | + @Override |
| 1438 | + public void getLogsAsync( |
| 1439 | + org.fisco.bcos.sdk.v3.client.protocol.request.EthFilter params, |
| 1440 | + RespCallback<EthLog> callback) { |
| 1441 | + this.asyncCallRemoteMethod( |
| 1442 | + this.groupID, |
| 1443 | + "", |
| 1444 | + new JsonRpcRequest<>(JsonRpcMethods.GET_LOGS, Arrays.asList(this.groupID, params)), |
| 1445 | + EthLog.class, |
| 1446 | + callback); |
| 1447 | + } |
| 1448 | + |
| 1449 | + @Override |
| 1450 | + public EthLog getFilterLogs(EthFilter filter) { |
| 1451 | + return this.callRemoteMethod( |
| 1452 | + this.groupID, |
| 1453 | + "", |
| 1454 | + new JsonRpcRequest<>( |
| 1455 | + JsonRpcMethods.GET_FILTER_LOGS, |
| 1456 | + Arrays.asList(this.groupID, filter.getResult())), |
| 1457 | + EthLog.class); |
| 1458 | + } |
| 1459 | + |
| 1460 | + @Override |
| 1461 | + public void getFilterLogsAsync(EthFilter filter, RespCallback<EthLog> callback) { |
| 1462 | + |
| 1463 | + this.asyncCallRemoteMethod( |
| 1464 | + this.groupID, |
| 1465 | + "", |
| 1466 | + new JsonRpcRequest<>( |
| 1467 | + JsonRpcMethods.GET_FILTER_LOGS, |
| 1468 | + Arrays.asList(this.groupID, filter.getResult())), |
| 1469 | + EthLog.class, |
| 1470 | + callback); |
| 1471 | + } |
| 1472 | + |
1316 | 1473 | @Override
|
1317 | 1474 | public void start() {
|
1318 | 1475 | if (rpcJniObj != null) {
|
@@ -1446,8 +1603,7 @@ public static <T extends JsonRpcResponse<?>> T parseResponseIntoJsonRpcResponse(
|
1446 | 1603 | if (response.getErrorCode() == 0) {
|
1447 | 1604 | // parse the response into JsonRPCResponse
|
1448 | 1605 | T jsonRpcResponse =
|
1449 |
| - ObjectMapperFactory.getObjectMapper() |
1450 |
| - .readValue(response.getContent(), responseType); |
| 1606 | + getObjectMapper().readValue(response.getContent(), responseType); |
1451 | 1607 | if (jsonRpcResponse.getError() != null) {
|
1452 | 1608 | logger.error(
|
1453 | 1609 | "parseResponseIntoJsonRpcResponse failed for non-empty error message, method: {}, retErrorMessage: {}, retErrorCode: {}",
|
|
0 commit comments