├── .gitignore ├── ChangeLog.md ├── LICENSE ├── README.md ├── WeBankBlockchain-Data-Export-sdk ├── WeBankBlockchain-Data-Export-common │ ├── .gitignore │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── webank │ │ └── blockchain │ │ └── data │ │ └── export │ │ └── common │ │ ├── bo │ │ ├── contract │ │ │ ├── ContractDetail.java │ │ │ ├── ContractMapsInfo.java │ │ │ ├── EventMetaInfo.java │ │ │ ├── FieldVO.java │ │ │ └── MethodMetaInfo.java │ │ └── data │ │ │ ├── BlockContractInfoBO.java │ │ │ ├── BlockDetailInfoBO.java │ │ │ ├── BlockInfoBO.java │ │ │ ├── BlockMethodInfo.java │ │ │ ├── BlockRawDataBO.java │ │ │ ├── BlockTxDetailInfoBO.java │ │ │ ├── CommonBO.java │ │ │ ├── ContractInfoBO.java │ │ │ ├── DeployedAccountInfoBO.java │ │ │ ├── EventBO.java │ │ │ ├── MethodBO.java │ │ │ ├── TxRawDataBO.java │ │ │ └── TxReceiptRawDataBO.java │ │ ├── client │ │ ├── ChainClient.java │ │ ├── ChannelClient.java │ │ ├── RpcHttpClient.java │ │ └── StashClient.java │ │ ├── constants │ │ ├── AbiTypeConstants.java │ │ ├── BinConstant.java │ │ ├── BlockConstants.java │ │ ├── ContractConstants.java │ │ └── StatusCode.java │ │ ├── entity │ │ ├── BlockDataSource.java │ │ ├── ChainInfo.java │ │ ├── ContractInfo.java │ │ ├── DataExportContext.java │ │ ├── ESDataSource.java │ │ ├── ExportConfig.java │ │ ├── ExportConstant.java │ │ ├── ExportDataSource.java │ │ ├── MysqlDataSource.java │ │ ├── StashInfo.java │ │ └── TableSQL.java │ │ ├── enums │ │ ├── BlockCertaintyEnum.java │ │ ├── DataType.java │ │ ├── IgnoreBasicDataParam.java │ │ └── TxInfoStatusEnum.java │ │ ├── stash │ │ ├── DataStashMysqlRepo.java │ │ ├── StashBlockDataParser.java │ │ ├── entity │ │ │ ├── BlockHeader.java │ │ │ ├── BlockV2RC2.java │ │ │ ├── Log.java │ │ │ ├── TransactionDetail.java │ │ │ └── TransactionReceipt.java │ │ └── rlp │ │ │ ├── ByteArrayWrapper.java │ │ │ ├── ByteUtil.java │ │ │ ├── CompactEncoder.java │ │ │ ├── DecodeResult.java │ │ │ ├── FastByteComparisons.java │ │ │ ├── RLP.java │ │ │ ├── RLPElement.java │ │ │ ├── RLPItem.java │ │ │ ├── RLPList.java │ │ │ └── Value.java │ │ ├── subscribe │ │ ├── DefaultMsgTopic.java │ │ ├── TopicRegistry.java │ │ └── face │ │ │ ├── MsgTopicInterface.java │ │ │ └── SubscriberInterface.java │ │ ├── tools │ │ ├── AddressListUtils.java │ │ ├── AddressUtils.java │ │ ├── BigIntegerUtils.java │ │ ├── BoolUtils.java │ │ ├── BytesUtils.java │ │ ├── ClazzScanUtils.java │ │ ├── ClientUtil.java │ │ ├── DateUtils.java │ │ ├── JacksonException.java │ │ ├── JacksonUtils.java │ │ ├── MessageLoader.java │ │ ├── MethodUtils.java │ │ ├── NameValueVO.java │ │ └── ResponseUtils.java │ │ └── vo │ │ ├── CommonDataResponse.java │ │ ├── CommonResponse.java │ │ └── ValidErrorResponse.java ├── WeBankBlockchain-Data-Export-core │ ├── .gitignore │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── webank │ │ └── blockchain │ │ └── data │ │ └── export │ │ ├── api │ │ └── DataExportService.java │ │ ├── exception │ │ └── CustomJobExceptionHandler.java │ │ ├── service │ │ ├── BlockAsyncService.java │ │ ├── BlockCheckService.java │ │ ├── BlockCrawlService.java │ │ ├── BlockDataResetService.java │ │ ├── BlockDepotService.java │ │ ├── BlockIndexService.java │ │ ├── BlockListenerService.java │ │ ├── BlockPrepareService.java │ │ ├── BlockStoreService.java │ │ └── RollBackService.java │ │ ├── task │ │ ├── CrawlRunner.java │ │ ├── DataExportExecutor.java │ │ ├── DataPersistenceManager.java │ │ ├── DepotJob.java │ │ └── PrepareTaskJob.java │ │ └── tools │ │ ├── DataSourceUtils.java │ │ └── ElasticJobUtil.java ├── WeBankBlockchain-Data-Export-db │ ├── .gitignore │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── webank │ │ └── blockchain │ │ └── data │ │ └── export │ │ └── db │ │ ├── dao │ │ ├── BlockDetailInfoDAO.java │ │ ├── BlockRawDataDAO.java │ │ ├── BlockTxDetailInfoDAO.java │ │ ├── ContractInfoDAO.java │ │ ├── DeployedAccountInfoDAO.java │ │ ├── ESHandleDao.java │ │ ├── MethodAndEventDao.java │ │ ├── SaveInterface.java │ │ ├── TxRawDataDAO.java │ │ └── TxReceiptRawDataDAO.java │ │ ├── entity │ │ ├── BlockDetailInfo.java │ │ ├── BlockRawData.java │ │ ├── BlockTaskPool.java │ │ ├── BlockTxDetailInfo.java │ │ ├── ContractInfo.java │ │ ├── DeployedAccountInfo.java │ │ ├── IdEntity.java │ │ ├── TxRawData.java │ │ └── TxReceiptRawData.java │ │ ├── repository │ │ ├── BlockDetailInfoRepository.java │ │ ├── BlockRawDataRepository.java │ │ ├── BlockTaskPoolRepository.java │ │ ├── BlockTxDetailInfoRepository.java │ │ ├── ContractInfoRepository.java │ │ ├── DeployedAccountInfoRepository.java │ │ ├── RollbackInterface.java │ │ ├── TxRawDataRepository.java │ │ └── TxReceiptRawDataRepository.java │ │ ├── service │ │ ├── DataStoreService.java │ │ ├── ESService.java │ │ ├── ESStoreService.java │ │ └── MysqlStoreService.java │ │ └── tools │ │ └── BeanUtils.java ├── WeBankBlockchain-Data-Export-parser │ ├── .gitignore │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── webank │ │ └── blockchain │ │ └── data │ │ └── export │ │ └── parser │ │ ├── contract │ │ ├── ContractParser.java │ │ ├── EventParser.java │ │ └── MethodParser.java │ │ ├── enums │ │ └── JavaTypeEnum.java │ │ ├── facade │ │ └── ParseFacade.java │ │ ├── handler │ │ ├── BlockCrawlerHandler.java │ │ ├── ContractCrawlerHandler.java │ │ ├── EventCrawlerHandler.java │ │ └── MethodCrawlerHandler.java │ │ ├── service │ │ ├── ContractConstructorService.java │ │ └── TransactionService.java │ │ └── tools │ │ ├── ABIUtils.java │ │ ├── SolJavaTypeMappingUtils.java │ │ └── SolSqlTypeMappingUtils.java ├── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── webank │ │ │ └── blockchain │ │ │ └── data │ │ │ └── export │ │ │ └── ExportDataSDK.java │ └── resources │ │ └── logback.xml │ └── test │ └── java │ └── com │ └── webank │ └── blockchain │ └── data │ └── export │ └── sdk │ └── test │ └── ExportDataTest.java ├── WeBankBlockchain-Data-Export-service ├── .gitignore ├── .travis.yml ├── build.gradle ├── data-export-docker │ ├── build_export.sh │ └── config │ │ ├── abi │ │ └── HelloWorld.abi │ │ ├── application.properties │ │ └── bin │ │ └── HelloWorld.bin ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── webank │ │ │ └── blockchain │ │ │ └── data │ │ │ └── export │ │ │ ├── App.java │ │ │ ├── config │ │ │ └── ServiceConfig.java │ │ │ ├── contract │ │ │ ├── ContractParser.java │ │ │ ├── EventParser.java │ │ │ └── MethodParser.java │ │ │ ├── grafana │ │ │ ├── AtomicParas.java │ │ │ ├── GrafanaConstant.java │ │ │ ├── GrafanaDashboardParas.java │ │ │ ├── GrafanaGenerateService.java │ │ │ ├── GrafanaPanelTableParasEvent.java │ │ │ ├── GrafanaPanelTableParasMethod.java │ │ │ └── GrafanaParas.java │ │ │ ├── service │ │ │ └── ExportService.java │ │ │ └── utils │ │ │ └── PropertiesUtils.java │ └── resources │ │ ├── application.properties │ │ └── templates │ │ └── grafana │ │ ├── dashboard_default.txt │ │ └── panel_table.txt │ └── test │ └── java │ └── com │ └── webank │ └── blockchain │ └── data │ └── export │ ├── grafana │ └── GrafanaDashboardParasTest.java │ └── utils │ └── PropertiesUtilsTest.java ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── tools ├── config ├── application.properties └── solidity │ └── HelloWorld.sol ├── start.sh └── stop.sh /.gitignore: -------------------------------------------------------------------------------- 1 | ### common ### 2 | log/ 3 | src/main/resources 4 | src/test/resources 5 | 6 | ### mac ### 7 | .DS_Store 8 | 9 | ### gradle ### 10 | .gradle/ 11 | build 12 | dist/ 13 | 14 | ## eclipse ## 15 | .classpath 16 | .project 17 | .settings 18 | bin/ 19 | out/ 20 | conf/ 21 | 22 | ## integration test files 23 | nodes/ 24 | src/integration-test/resources/ 25 | build_chain.sh 26 | 27 | ### STS ### 28 | .apt_generated 29 | .factorypath 30 | .springBeans 31 | .sts4-cache 32 | 33 | ### IntelliJ IDEA ### 34 | .idea 35 | *.iws 36 | *.iml 37 | *.ipr 38 | 39 | ### NetBeans ### 40 | /nbproject/private/ 41 | /build/ 42 | /nbbuild/ 43 | /dist/ 44 | /nbdist/ 45 | /.nb-gradle/ 46 | 47 | ### Compiled class file ### 48 | *.class 49 | 50 | ### Log file ### 51 | *.log 52 | 53 | ### BlueJ files ### 54 | *.ctxt 55 | 56 | ### Mobile Tools for Java (J2ME) ### 57 | .mtj.tmp/ 58 | 59 | ### Package Files ### 60 | *.jar 61 | *.war 62 | *.nar 63 | *.ear 64 | *.zip 65 | *.tar.gz 66 | *.rar 67 | 68 | ### virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml ### 69 | hs_err_pid* 70 | 71 | ### repo ### 72 | config/ 73 | generated -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # WeBankBlockchain-Data-Export 3 | 4 | [](https://www.apache.org/licenses/LICENSE-2.0.html) 5 | 6 | > 穿花度柳飞如箭, 7 | > 粘絮寻香似落星。 8 | > 小小微躯能负重, 9 | > 器器薄翅会乘风。 10 | > -- 吴承恩 11 | 12 | 13 | WeBankBlockchain-Data-Export 是一个基于[FISCO-BCOS](https://github.com/FISCO-BCOS/FISCO-BCOS)平台的数据导出工具。 14 | 15 | 数据导出组件WeBankBlockchain-Data-Export的目的在于降低获取区块链数据的开发门槛,提升研发效率。研发人员几乎不需要编写任何代码,只需要进行简单配置,就可以把数据导出到Mysql数据库。 16 | 17 | WeBankBlockchain-Data-Export可以导出区块链上的基础数据,如当前块高、交易总量等。如果配置了FISCO-BCOS上运行合约的相关信息,还可导出链上合约的业务数据,包括event、构造函数、合约地址、执行函数的信息等。 18 | 19 | **此版本只支持**[FISCO BCOS 2.0](https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/)及以上版本。 20 | 21 | 22 | ## 关键特性 23 | 24 | - 支持JSON-RPC、Channel通道、数据仓库源等方式导出数据 25 | 26 | - 支持服务和docker方式部署 27 | 28 | - 支持多数据源,支持分库分表 29 | 30 | - 支持ES存储 31 | 32 | - 支持多活部署,多节点自动导出 33 | 34 | - 支持自定义导出数据内容 35 | 36 | - 提供SDK的集成方式 37 | 38 | - 支持可视化的监控页面 39 | 40 | 41 | ## 环境要求 42 | 43 | 在使用本组件前,请确认系统环境已安装相关依赖软件,清单如下: 44 | 45 | | 依赖软件 | 说明 |备注| 46 | | --- | --- | --- | 47 | | FISCO-BCOS | >= 2.0, 1.x版本请参考V0.5版本 dev分支 | 48 | | Bash | 需支持Bash(理论上来说支持所有ksh、zsh等其他unix shell,但未测试)| 49 | | Java | JDK[1.8] || 50 | | Git | 下载的安装包使用Git | | 51 | | MySQL | >= mysql-community-server[5.7] | 理论上来说支持主流数据库,但未测试| 52 | | zookeeper | >= zookeeper[3.4] | 只有在进行集群部署的时候需要安装| 53 | | docker | >= docker[18.0.0] | 只有需要可视化监控页面的时候才需要安装| 54 | | ElasticSearch | >= elasticsearch [7.0] | 只有在需要ES存储时安装 | 55 | 56 | 57 | ## 文档 58 | - [**中文**](https://data-doc.readthedocs.io/zh_CN/latest/docs/WeBankBlockchain-Data-Export/index.html) 59 | - [**快速安装**](https://data-doc.readthedocs.io/zh_CN/latest/docs/WeBankBlockchain-Data-Export/install.html) 60 | 61 | 62 | ## 贡献代码 63 | 欢迎参与本项目的社区建设: 64 | - 如项目对您有帮助,欢迎点亮我们的小星星(点击项目右上方Star按钮)。 65 | - 欢迎提交代码(Pull requests)。 66 | - [提问和提交BUG](https://github.com/WeBankBlockchain/WeBankBlockchain-Data-Export/issues)。 67 | - 如果发现代码存在安全漏洞,请在[这里](https://security.webank.com)上报。 68 | 69 | 70 | ## License 71 |  72 | 73 | 开源协议为[Apache License 2.0](http://www.apache.org/licenses/). 详情参考[LICENSE](../LICENSE)。 74 | -------------------------------------------------------------------------------- /WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | /bin/ 4 | bin/* 5 | config/* 6 | /.gradle/ 7 | 8 | 9 | 10 | ### STS ### 11 | .apt_generated 12 | .classpath 13 | .factorypath 14 | .project 15 | .settings 16 | .springBeans 17 | .sts4-cache 18 | 19 | ### IntelliJ IDEA ### 20 | .idea 21 | *.iws 22 | *.iml 23 | *.ipr 24 | 25 | ### NetBeans ### 26 | /nbproject/private/ 27 | /build/ 28 | /nbbuild/ 29 | /dist/ 30 | /nbdist/ 31 | /.nb-gradle/ 32 | 33 | src/main/scripts 34 | src/main/resources 35 | 36 | ## contracts ## 37 | src/main/java/com/webank/bcosexport/generated 38 | src/main/java/com/webank/blockchain.data.export/generated 39 | src/main/java/org 40 | my.log* 41 | *.log 42 | 43 | src/test/java/com/webank/webaseexport/contract/ 44 | -------------------------------------------------------------------------------- /WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/build.gradle: -------------------------------------------------------------------------------- 1 | clean { 2 | println "delete ${projectDir}/dist" 3 | delete "${projectDir}/dist" 4 | } 5 | 6 | 7 | -------------------------------------------------------------------------------- /WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/bo/contract/ContractDetail.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2020 Webank. 3 | * 4 | *
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *
http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *
Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.contract;
15 |
16 | import com.webank.blockchain.data.export.common.bo.data.ContractInfoBO;
17 | import lombok.Data;
18 | import lombok.experimental.Accessors;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * ContractMethodInfo
24 | *
25 | * @Description: ContractMethodInfo storages all contracts info for parsing method data.
26 | * @author graysonzhang
27 | * @data 2018-12-17 11:48:31
28 | *
29 | */
30 | @Data
31 | @Accessors(chain = true)
32 | public class ContractDetail {
33 |
34 | private ContractInfoBO contractInfoBO;
35 |
36 | private List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.contract;
15 |
16 | import lombok.Data;
17 | import lombok.experimental.Accessors;
18 |
19 | import java.util.Map;
20 |
21 | /**
22 | * ContractMapsInfo
23 | *
24 | * @Description: ContractMapsInfo storages contract info, that will used to parse method data.
25 | * @author graysonzhang
26 | * @data 2018-12-17 14:55:20
27 | *
28 | */
29 | @Data
30 | @Accessors(chain = true)
31 | public class ContractMapsInfo {
32 |
33 | /** @Fields methodIdMap : use to storage methodId map , key:methodId, value:(contractName, methodName) */
34 | private Map Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.contract;
15 |
16 | import lombok.Data;
17 | import lombok.NoArgsConstructor;
18 | import lombok.experimental.Accessors;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * EventMetaInfo
24 | *
25 | * @Description: EventMetaInfo storages event config data for parsing event data
26 | * @author maojiayu
27 | * @author graysonzhang
28 | * @data 2018-11-08 22:03:20
29 | *
30 | */
31 | @Data
32 | @NoArgsConstructor
33 | @Accessors(chain = true)
34 | public class EventMetaInfo {
35 |
36 | /** @Fields eventName : event name */
37 | private String eventName;
38 |
39 | /** @Fields contractName : contract name */
40 | private String contractName;
41 |
42 | /** @Fields list : event filed list */
43 | private List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.contract;
15 |
16 | import lombok.Data;
17 | import lombok.experimental.Accessors;
18 |
19 | /**
20 | * FieldVO stores one single field of a contract field.
21 | *
22 | * @author maojiayu
23 | * @data Dec 28, 2018 5:06:04 PM
24 | *
25 | */
26 | @Data
27 | @Accessors(chain = true)
28 | public class FieldVO {
29 | private String sqlName;
30 | private String solidityName;
31 | private String javaName;
32 | private String sqlType;
33 | private String solidityType;
34 | private String javaType;
35 | private String javaCapName; // 首字母大写
36 | private String typeMethod; // 转化方法
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/bo/contract/MethodMetaInfo.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.contract;
15 |
16 | import java.util.List;
17 |
18 | import lombok.Data;
19 | import lombok.experimental.Accessors;
20 |
21 | /**
22 | * MethodMetaInfo
23 | *
24 | * @Description: MethodMetaInfo storages method config data for parsing method data.
25 | * @author graysonzhang
26 | * @data 2018-12-17 14:20:00
27 | *
28 | */
29 | @Data
30 | @Accessors(chain = true)
31 | public class MethodMetaInfo {
32 |
33 | /** @Fields methodId : method id */
34 | private String methodId;
35 |
36 | /** @Fields methodName : method name */
37 | private String methodName;
38 |
39 | private String originName;
40 |
41 | private String type;
42 |
43 | /** @Fields contractName : contract name */
44 | private String contractName;
45 |
46 | /** @Fields fieldsList : method input param list */
47 | private List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.data;
15 |
16 | import lombok.Data;
17 | import lombok.experimental.Accessors;
18 |
19 | import java.util.Date;
20 |
21 | /**
22 | * BlockDetailInfo
23 | *
24 | * @Description: BlockDetailInfo
25 | * @author maojiayu
26 | * @data Jul 1, 2019 4:16:27 PM
27 | *
28 | */
29 | @Data
30 | @Accessors(chain = true)
31 | public class BlockDetailInfoBO {
32 |
33 | /** @Fields blockHeight : block height */
34 | private long blockHeight;
35 |
36 | /** @Fields blockHash : block hash */
37 | private String blockHash;
38 |
39 | /** @Fields txCount : transaction's count in block */
40 | private int txCount;
41 |
42 | /** @Fields blockTimeStamp : block timestamp */
43 | private Date blockTimeStamp;
44 |
45 | private short status;
46 |
47 | public enum Status {
48 | TODO, COMPLETED
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/bo/data/BlockInfoBO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.data;
15 |
16 | import lombok.Data;
17 | import lombok.experimental.Accessors;
18 |
19 | import java.util.List;
20 |
21 | /**
22 | * BlockInfoBO
23 | *
24 | * @Description: BlockInfoBO
25 | * @author maojiayu
26 | * @data Jul 1, 2019 8:55:51 PM
27 | *
28 | */
29 | @Data
30 | @Accessors(chain = true)
31 | public class BlockInfoBO {
32 | private BlockDetailInfoBO blockDetailInfo;
33 |
34 | private BlockRawDataBO blockRawDataBO;
35 |
36 | private List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.data;
15 |
16 | import lombok.Data;
17 | import lombok.experimental.Accessors;
18 |
19 | import java.util.List;
20 | import java.util.Map;
21 |
22 | /**
23 | * BlockMethodInfo
24 | *
25 | * @Description: BlockMethodInfo
26 | * @author maojiayu
27 | * @data Jul 3, 2019 2:59:33 PM
28 | *
29 | */
30 | @Data
31 | @Accessors(chain = true)
32 | public class BlockMethodInfo {
33 |
34 | private List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.data;
15 |
16 | import com.fasterxml.jackson.annotation.JsonInclude;
17 | import lombok.Data;
18 | import lombok.experimental.Accessors;
19 |
20 | import java.util.Date;
21 |
22 | /**
23 | * BlockTxDetailInfo
24 | *
25 | * @Description: BlockTxDetailInfo
26 | * @author maojiayu
27 | * @data Jul 1, 2019 4:16:12 PM
28 | *
29 | */
30 | @Data
31 | @Accessors(chain = true)
32 | @JsonInclude(JsonInclude.Include.NON_NULL)
33 | public class BlockTxDetailInfoBO {
34 |
35 | /** @Fields blockHeight : block height */
36 | private String blockHeight;
37 |
38 | /** @Fields blockHash : block hash */
39 | private String blockHash;
40 |
41 | /** @Fields contractName : contract name */
42 | private String contractName;
43 |
44 | /** @Fields methodName : contract method name */
45 | private String methodName;
46 |
47 | /** @Fields txHash : transaction hash */
48 | private String txHash;
49 |
50 | /** @Fields txFrom : transaction' s from */
51 | private String txFrom;
52 |
53 | /** @Fields txTo : transaction's to */
54 | private String txTo;
55 |
56 | /** @Fields blockTimeStamp : block timestamp */
57 | private Date blockTimeStamp;
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/bo/data/CommonBO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.data;
15 |
16 | import lombok.Data;
17 |
18 | import java.util.Map;
19 |
20 | /**
21 | * CommonBO
22 | *
23 | * @Description: CommonBO
24 | * @author maojiayu
25 | * @data Jul 7, 2019 3:05:17 PM
26 | *
27 | */
28 | @Data
29 | public class CommonBO {
30 | private String table;
31 | private Map Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.data;
15 |
16 | import lombok.Data;
17 | import lombok.EqualsAndHashCode;
18 | import lombok.experimental.Accessors;
19 |
20 | /**
21 | * EventBo
22 | *
23 | * @Description: EventBo
24 | * @author maojiayu
25 | * @data Jul 2, 2019 3:34:31 PM
26 | *
27 | */
28 | @Data
29 | @EqualsAndHashCode(callSuper = false)
30 | @Accessors(chain = true)
31 | public class EventBO extends CommonBO{
32 |
33 | private String toAddress;
34 | }
35 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/bo/data/MethodBO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.bo.data;
15 |
16 | import lombok.Data;
17 | import lombok.EqualsAndHashCode;
18 | import lombok.experimental.Accessors;
19 |
20 | /**
21 | * EventBo
22 | *
23 | * @Description: EventBo
24 | * @author maojiayu
25 | * @data Jul 2, 2019 3:34:31 PM
26 | *
27 | */
28 | @Data
29 | @Accessors(chain = true)
30 | @EqualsAndHashCode(callSuper = false)
31 | public class MethodBO extends CommonBO{
32 |
33 | private String toAddress;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/bo/data/TxRawDataBO.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.bo.data;
2 |
3 | import lombok.Data;
4 | import lombok.experimental.Accessors;
5 |
6 | import java.util.Date;
7 |
8 | /**
9 | * @author wesleywang
10 | * @Description:
11 | * @date 2020/10/26
12 | */
13 | @Data
14 | @Accessors(chain = true)
15 | public class TxRawDataBO {
16 |
17 | private long blockHeight;
18 |
19 | private String blockHash;
20 |
21 | private String txHash;
22 |
23 | private String txIndex;
24 |
25 | private Date blockTimeStamp;
26 |
27 | private String from;
28 | private String gas;
29 | private String input;
30 | private String nonce;
31 | private String to;
32 | private String value;
33 | private String gasPrice;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/bo/data/TxReceiptRawDataBO.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.bo.data;
2 |
3 | import com.fasterxml.jackson.annotation.JsonInclude;
4 | import lombok.Data;
5 | import lombok.experimental.Accessors;
6 |
7 | import java.util.Date;
8 |
9 | /**
10 | * @author wesleywang
11 | * @Description:
12 | * @date 2020/10/26
13 | */
14 | @Data
15 | @Accessors(chain = true)
16 | @JsonInclude(JsonInclude.Include.NON_NULL)
17 | public class TxReceiptRawDataBO {
18 |
19 | private long blockHeight;
20 |
21 | private String blockHash;
22 |
23 | private String txHash;
24 |
25 | private Date blockTimeStamp;
26 |
27 | private String txIndex;
28 | private String root;
29 | private String from;
30 | private String to;
31 | private String gasUsed;
32 | private String contractAddress;
33 | private String logs;
34 | private String logsBloom;
35 | private String status;
36 | private String input;
37 | private String output;
38 | private String txProof;
39 | private String receiptProof;
40 | private String message;
41 | }
42 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/client/ChainClient.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.client;
2 |
3 |
4 | import org.fisco.bcos.sdk.client.protocol.response.BcosBlock;
5 | import org.fisco.bcos.sdk.client.protocol.response.BcosTransaction;
6 | import org.fisco.bcos.sdk.client.protocol.response.BcosTransactionReceipt;
7 | import org.fisco.bcos.sdk.crypto.CryptoSuite;
8 |
9 | import java.math.BigInteger;
10 |
11 | /**
12 | * @author wesleywang
13 | * @Description:
14 | * @date 2021/2/25
15 | */
16 | public interface ChainClient {
17 |
18 | BcosBlock.Block getBlockByNumber(BigInteger blockNumber);
19 |
20 | BigInteger getBlockNumber();
21 |
22 | String getCode(String address);
23 |
24 | CryptoSuite getCryptoSuite();
25 |
26 | BcosTransaction getTransactionByHash(String transactionHash);
27 |
28 | BcosTransactionReceipt getTransactionReceipt(String transactionHash);
29 | }
30 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/client/ChannelClient.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.client;
2 |
3 | import com.webank.blockchain.data.export.common.entity.ChainInfo;
4 | import com.webank.blockchain.data.export.common.entity.ExportConstant;
5 | import com.webank.blockchain.data.export.common.tools.ClientUtil;
6 | import lombok.extern.slf4j.Slf4j;
7 | import org.fisco.bcos.sdk.client.Client;
8 | import org.fisco.bcos.sdk.client.protocol.response.BcosBlock;
9 | import org.fisco.bcos.sdk.client.protocol.response.BcosTransaction;
10 | import org.fisco.bcos.sdk.client.protocol.response.BcosTransactionReceipt;
11 | import org.fisco.bcos.sdk.config.exceptions.ConfigException;
12 | import org.fisco.bcos.sdk.crypto.CryptoSuite;
13 |
14 | import java.math.BigInteger;
15 |
16 | /**
17 | * @author wesleywang
18 | * @Description:
19 | * @date 2021/2/25
20 | */
21 | @Slf4j
22 | public class ChannelClient implements ChainClient {
23 |
24 | private Client client;
25 |
26 | public ChannelClient() throws ConfigException {
27 | ChainInfo chainInfo = ExportConstant.getCurrentContext().getChainInfo();
28 | try {
29 | client = ClientUtil.getClient(chainInfo);
30 | } catch (ConfigException e) {
31 | log.error("channel client build failed , reason : ", e);
32 | throw e;
33 | }
34 | }
35 |
36 | @Override
37 | public BcosBlock.Block getBlockByNumber(BigInteger blockNumber) {
38 | return client.getBlockByNumber(blockNumber,true).getBlock();
39 | }
40 |
41 | @Override
42 | public BigInteger getBlockNumber() {
43 | return client.getBlockNumber().getBlockNumber();
44 | }
45 |
46 | @Override
47 | public String getCode(String address) {
48 | return client.getCode(address).getCode();
49 | }
50 |
51 | @Override
52 | public CryptoSuite getCryptoSuite() {
53 | return client.getCryptoSuite();
54 | }
55 |
56 | @Override
57 | public BcosTransaction getTransactionByHash(String transactionHash) {
58 | return client.getTransactionByHash(transactionHash);
59 | }
60 |
61 | @Override
62 | public BcosTransactionReceipt getTransactionReceipt(String hash) {
63 | return client.getTransactionReceipt(hash);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/client/StashClient.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.client;
2 |
3 | import com.webank.blockchain.data.export.common.entity.ExportConstant;
4 | import com.webank.blockchain.data.export.common.stash.DataStashMysqlRepo;
5 | import com.webank.blockchain.data.export.common.stash.StashBlockDataParser;
6 | import lombok.Data;
7 | import org.fisco.bcos.sdk.client.protocol.response.BcosBlock;
8 | import org.fisco.bcos.sdk.client.protocol.response.BcosTransaction;
9 | import org.fisco.bcos.sdk.client.protocol.response.BcosTransactionReceipt;
10 | import org.fisco.bcos.sdk.crypto.CryptoSuite;
11 |
12 | import java.math.BigInteger;
13 |
14 | /**
15 | * @author wesleywang
16 | * @Description:
17 | * @date 2021/3/3
18 | */
19 | @Data
20 | public class StashClient implements ChainClient {
21 |
22 | private DataStashMysqlRepo stashMysqlRepo;
23 |
24 | private StashBlockDataParser blockDataParser;
25 |
26 | private CryptoSuite cryptoSuite;
27 |
28 | public StashClient () {
29 | cryptoSuite = new CryptoSuite(ExportConstant.getCurrentContext().getStashInfo().getCryptoTypeConfig());
30 | stashMysqlRepo = DataStashMysqlRepo.create();
31 | blockDataParser = new StashBlockDataParser(stashMysqlRepo, cryptoSuite);
32 | }
33 |
34 | @Override
35 | public BcosBlock.Block getBlockByNumber(BigInteger blockNumber) {
36 | String blockStr = stashMysqlRepo.queryBlock(blockNumber.longValue());
37 | return blockDataParser.parse(blockStr);
38 | }
39 |
40 | @Override
41 | public BigInteger getBlockNumber() {
42 | long blockNumber = stashMysqlRepo.queryBlockNumber();
43 | return BigInteger.valueOf(blockNumber);
44 | }
45 |
46 | @Override
47 | public String getCode(String address) {
48 | return stashMysqlRepo.queryCode(address);
49 | }
50 |
51 | @Override
52 | public CryptoSuite getCryptoSuite() {
53 | return cryptoSuite;
54 | }
55 |
56 | @Override
57 | public BcosTransaction getTransactionByHash(String transactionHash) {
58 | return blockDataParser.getTransaction(transactionHash);
59 | }
60 |
61 | @Override
62 | public BcosTransactionReceipt getTransactionReceipt(String transactionHash) {
63 | return blockDataParser.getReceipt(transactionHash);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/constants/AbiTypeConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.constants;
15 |
16 | /**
17 | * AbiTypeConstants
18 | *
19 | * @Description: AbiTypeConstants
20 | * @author graysonzhang
21 | * @data 2018-12-4 20:02:13
22 | *
23 | */
24 | public class AbiTypeConstants {
25 |
26 | /** @Fields ABI_FUNCTION_TYPE : contract function type */
27 | public static final String ABI_FUNCTION_TYPE = "function";
28 |
29 | /** @Fields ABI_CONSTRUCTOR_TYPE : contract constructor type */
30 | public static final String ABI_CONSTRUCTOR_TYPE = "constructor";
31 |
32 | /** @Fields ABI_EVENT_TYPE : contract event type */
33 | public static final String ABI_EVENT_TYPE = "event";
34 |
35 | /** @Fields ABI_CONST_TYPE : contract const method type */
36 | public static final String ABI_CONST_TYPE = "const";
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/constants/BinConstant.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.constants;
15 |
16 | /**
17 | * BinConstant
18 | *
19 | * @Description: BinConstant
20 | * @author maojiayu
21 | * @data Jun 13, 2019 3:08:06 PM
22 | *
23 | */
24 | public class BinConstant {
25 |
26 | public static final int META_DATA_HASH_LENGTH = 64 + 4;
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/constants/BlockConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.constants;
15 |
16 | /**
17 | * BlockForkConstants
18 | *
19 | * @Description: BlockForkConstants
20 | * @author maojiayu
21 | * @data Apr 1, 2019 3:56:30 PM
22 | *
23 | */
24 | public class BlockConstants {
25 |
26 | public static final int MAX_FORK_CERTAINTY_BLOCK_NUMBER = 6;
27 | public static final int DEPOT_TIME_OUT = 300;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/constants/ContractConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.constants;
15 |
16 | import com.webank.blockchain.data.export.common.bo.contract.ContractMapsInfo;
17 |
18 | /**
19 | * ContractConstants
20 | *
21 | * @Description: ContractConstants
22 | * @author maojiayu
23 | * @data Jul 23, 2019 10:19:34 AM
24 | *
25 | */
26 | public class ContractConstants {
27 |
28 | public static final String EMPTY_ADDRESS = "0x0000000000000000000000000000000000000000";
29 |
30 | public final static ThreadLocal Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.constants;
15 |
16 | /**
17 | * Common Status Code.
18 | *
19 | * @author maojiayu
20 | * @data Dec 28, 2018 5:24:46 PM
21 | *
22 | */
23 | public class StatusCode {
24 | public static int SUCCESS = 0; // 成功
25 | public static int EXECUTE_ERROR = 2; // 执行错误
26 | public static int SESSION_EXPIRED = 3; // 会话已经过期,请重新登录
27 | public static int UNAUTH = 4; // 用户无权限访问
28 | public static int APP_OUTER_DEPENDENCY_ERROR = 5; // 外部依赖错误
29 | public static int EXCEPTION_OCCUR = 6; // 发生异常
30 | public static int PARAMETER_ERROR = 7; // 参数错误
31 | public static int RESULT_EMPTY = 8; // 不存在请求内容
32 | public static int STATUS_ERROR = 9; // 状态错误
33 | }
34 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/entity/BlockDataSource.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.entity;
2 |
3 | /**
4 | * @author wesleywang
5 | * @Description:
6 | * @date 2021/3/3
7 | */
8 | public class BlockDataSource {
9 | }
10 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/entity/ChainInfo.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.entity;
2 |
3 | import lombok.Builder;
4 | import lombok.Data;
5 | import lombok.EqualsAndHashCode;
6 |
7 | /**
8 | * @author wesleywang
9 | * @Description:
10 | * @date 2020/12/16
11 | */
12 | @EqualsAndHashCode(callSuper = true)
13 | @Data
14 | @Builder
15 | public class ChainInfo extends BlockDataSource {
16 |
17 | private String nodeStr;
18 | private int groupId;
19 | private String certPath;
20 | //0-ECDSA,1-SM
21 | private int cryptoTypeConfig;
22 | private String rpcUrl;
23 | }
24 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/entity/ContractInfo.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.entity;
2 |
3 | import lombok.Data;
4 | import lombok.experimental.Accessors;
5 |
6 | /**
7 | * @author wesleywang
8 | * @Description:
9 | * @date 2020/12/25
10 | */
11 | @Data
12 | @Accessors(chain = true)
13 | public class ContractInfo {
14 |
15 | private String contractName;
16 |
17 | private String abi;
18 |
19 | private String binary;
20 |
21 | private short version;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/entity/DataExportContext.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.entity;
2 |
3 | import com.webank.blockchain.data.export.common.client.ChainClient;
4 | import com.webank.blockchain.data.export.common.subscribe.TopicRegistry;
5 | import lombok.Data;
6 | import org.elasticsearch.client.transport.TransportClient;
7 | import org.fisco.bcos.sdk.transaction.codec.decode.TransactionDecoderInterface;
8 |
9 | import javax.sql.DataSource;
10 | import java.util.Map;
11 |
12 | /**
13 | * @author wesleywang
14 | * @Description:
15 | * @date 2020/12/16
16 | */
17 | @Data
18 | @SuppressWarnings("deprecation")
19 | public class DataExportContext {
20 |
21 | private DataSource dataSource;
22 |
23 | private ExportDataSource exportDataSource;
24 |
25 | private TransportClient esClient;
26 |
27 | private ESDataSource esConfig;
28 |
29 | private ChainInfo chainInfo;
30 |
31 | private StashInfo stashInfo;
32 |
33 | private DataSource stashDataSource;
34 |
35 | private ExportConfig config;
36 |
37 | private ChainClient client;
38 |
39 | private boolean autoCreateTable;
40 |
41 | private TransactionDecoderInterface decoder;
42 |
43 | private Map Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.enums;
15 |
16 | import lombok.AllArgsConstructor;
17 | import lombok.Getter;
18 |
19 | /**
20 | * BlockCertaintyEnum
21 | *
22 | * @Description: BlockCertaintyEnum
23 | * @author maojiayu
24 | * @data Apr 1, 2019 3:58:30 PM
25 | *
26 | */
27 | @AllArgsConstructor
28 | @Getter
29 | public enum BlockCertaintyEnum {
30 | UNCERTAIN(0), FIXED(1);
31 | private int certainty;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/enums/DataType.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.enums;
2 |
3 | import cn.hutool.core.collection.CollectionUtil;
4 | import cn.hutool.core.collection.ListUtil;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Getter;
7 |
8 | import java.util.Collections;
9 | import java.util.List;
10 | import java.util.stream.Collectors;
11 |
12 | /**
13 | * @author wesleywang
14 | * @Description:
15 | * @date 2020/12/23
16 | */
17 | @AllArgsConstructor
18 | @Getter
19 | public enum DataType {
20 |
21 | NULL("null"),
22 | BLOCK_DETAIL_INFO_TABLE("block_detail_info"),
23 | BLOCK_RAW_DATA_TABLE("block_raw_data"),
24 | BLOCK_TX_DETAIL_INFO_TABLE("block_tx_detail_info"),
25 | TX_RAW_DATA_TABLE("tx_raw_data"),
26 | TX_RECEIPT_RAW_DATA_TABLE("tx_receipt_raw_data"),
27 | DEPLOYED_ACCOUNT_INFO_TABLE("deployed_account_info"),
28 | CONTRACT_INFO_TABLE("contract_info"),
29 | BLOCK_TASK_POOL_TABLE("block_task_pool"),
30 | EVENT_TABLE("event"),
31 | METHOD_TABLE("method");
32 |
33 |
34 | private String tableName;
35 |
36 | public static List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.enums;
15 |
16 | import lombok.AllArgsConstructor;
17 | import lombok.Getter;
18 |
19 | /**
20 | * TxInfoStatusEnum
21 | *
22 | * @Description: TxInfoStatusEnum
23 | * @author maojiayu
24 | * @data Dec 13, 2018 8:48:55 PM
25 | *
26 | */
27 | @AllArgsConstructor
28 | @Getter
29 | public enum TxInfoStatusEnum {
30 |
31 | INIT(0), DOING(1), DONE(2), ERROR(3), TIMEOUT(4), RESET(5);
32 | private int status;
33 | }
34 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/stash/DataStashMysqlRepo.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.stash;
2 |
3 | import cn.hutool.db.Db;
4 | import cn.hutool.db.Entity;
5 | import com.webank.blockchain.data.export.common.entity.ExportConstant;
6 | import lombok.extern.slf4j.Slf4j;
7 |
8 | import java.sql.SQLException;
9 |
10 | /**
11 | * @author wesleywang
12 | * @Description:
13 | * @date 2021/3/3
14 | */
15 | @Slf4j
16 | public class DataStashMysqlRepo {
17 |
18 | private final Db stashDb;
19 |
20 | public static DataStashMysqlRepo create() {
21 | return new DataStashMysqlRepo();
22 | }
23 |
24 | public DataStashMysqlRepo() {
25 | stashDb = Db.use(ExportConstant.getCurrentContext().getStashDataSource());
26 | }
27 |
28 | public String queryBlock(long blockHeight){
29 | try {
30 | return stashDb.queryString(
31 | "select value from _sys_hash_2_block_ where _num_ = ? ", blockHeight);
32 | } catch (SQLException e) {
33 | log.error(" DataStashMysqlRepo queryBlock failed ", e);
34 | }
35 | return null;
36 | }
37 |
38 | public long queryBlockHeight(String transactionHash){
39 | try {
40 | Number height = stashDb.queryNumber(
41 | "select _num_ from _sys_tx_hash_2_block_ where _hash_ = ? ", transactionHash);
42 | if (height == null) {
43 | return -1;
44 | }
45 | return height.longValue();
46 | } catch (SQLException e) {
47 | log.warn(" DataStashMysqlRepo queryBlock failed ", e);
48 | }
49 | return -1;
50 | }
51 |
52 |
53 | public long queryBlockNumber(){
54 | try {
55 | return stashDb.count(Entity.create("_sys_hash_2_block_")) - 1;
56 | } catch (SQLException e) {
57 | log.error(" DataStashMysqlRepo queryBlockNumber failed ", e);
58 | }
59 | return -1;
60 | }
61 |
62 | public String queryCode(String contractAddress) {
63 | try {
64 | String contractTable = "c_" + contractAddress.replace("0x","");
65 | return stashDb.queryString(
66 | "select value from " + contractTable + " where " + contractTable +".key = ?", "code");
67 | } catch (SQLException e) {
68 | if (e.getErrorCode() == 1146 || e.getMessage().contains("doesn't exist")) {
69 | log.warn("the stash table contractAddress: {} not find ", contractAddress);
70 | return null;
71 | }
72 | log.warn("DataStashMysqlRepo queryCode failed ", e);
73 | }
74 | return null;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/stash/entity/Log.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.stash.entity;
2 |
3 | import com.webank.blockchain.data.export.common.stash.rlp.ByteUtil;
4 | import com.webank.blockchain.data.export.common.stash.rlp.RLPList;
5 | import lombok.Data;
6 | import lombok.EqualsAndHashCode;
7 | import lombok.experimental.Accessors;
8 | import org.fisco.bcos.sdk.abi.datatypes.Address;
9 | import org.fisco.bcos.sdk.utils.Numeric;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | * @author wesleywang
15 | * @Description:
16 | * @date 2021/3/4
17 | */
18 | @Data
19 | @Accessors
20 | @EqualsAndHashCode
21 | public class Log {
22 |
23 | private String address;
24 | private List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.stash.entity;
15 |
16 | import com.webank.blockchain.data.export.common.stash.rlp.ByteUtil;
17 | import com.webank.blockchain.data.export.common.stash.rlp.RLPList;
18 | import lombok.Data;
19 | import lombok.EqualsAndHashCode;
20 | import lombok.experimental.Accessors;
21 | import org.fisco.bcos.sdk.abi.datatypes.Address;
22 | import org.fisco.bcos.sdk.utils.Numeric;
23 |
24 | import java.math.BigInteger;
25 |
26 | /**
27 | * TransactionDetail
28 | *
29 | * @Description: TransactionDetail
30 | * @author maojiayu
31 | * @data Sep 10, 2019 8:02:42 PM
32 | *
33 | */
34 | @Data
35 | @Accessors
36 | @EqualsAndHashCode
37 | public class TransactionDetail {
38 | private BigInteger nonce;
39 | private BigInteger gasPrice;
40 | private BigInteger gas;
41 | private BigInteger blockLimit;
42 | private Address receiveAddress;
43 | private BigInteger value;
44 | private String data;
45 | private BigInteger chainId;
46 | private BigInteger groupId;
47 | private String v;
48 | private BigInteger r;
49 | private BigInteger s;
50 | private String extraData;
51 | private String hash;
52 |
53 | public TransactionDetail(RLPList rlpHeader) {
54 | this.nonce = ByteUtil.bytesToBigInteger(rlpHeader.get(0).getRLPData());
55 | this.gasPrice = ByteUtil.bytesToBigInteger(rlpHeader.get(1).getRLPData());
56 | this.gas = ByteUtil.bytesToBigInteger(rlpHeader.get(2).getRLPData());
57 | this.blockLimit = ByteUtil.bytesToBigInteger(rlpHeader.get(3).getRLPData());
58 | this.receiveAddress = new Address(ByteUtil.bytesToBigInteger(rlpHeader.get(4).getRLPData()));
59 | this.value = ByteUtil.bytesToBigInteger(rlpHeader.get(5).getRLPData());
60 | this.data = Numeric.toHexString(rlpHeader.get(6).getRLPData());
61 | this.chainId = ByteUtil.bytesToBigInteger(rlpHeader.get(7).getRLPData());
62 | this.groupId = ByteUtil.bytesToBigInteger(rlpHeader.get(8).getRLPData());
63 | this.extraData = Numeric.toHexString(rlpHeader.get(9).getRLPData());
64 | this.v = Numeric.toHexString(rlpHeader.get(10).getRLPData());
65 | this.r = ByteUtil.bytesToBigInteger(rlpHeader.get(11).getRLPData());
66 | this.s = ByteUtil.bytesToBigInteger(rlpHeader.get(12).getRLPData());
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/stash/entity/TransactionReceipt.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.stash.entity;
15 |
16 | import com.webank.blockchain.data.export.common.stash.rlp.ByteUtil;
17 | import com.webank.blockchain.data.export.common.stash.rlp.RLP;
18 | import com.webank.blockchain.data.export.common.stash.rlp.RLPElement;
19 | import com.webank.blockchain.data.export.common.stash.rlp.RLPList;
20 | import lombok.Data;
21 | import lombok.EqualsAndHashCode;
22 | import lombok.experimental.Accessors;
23 | import org.fisco.bcos.sdk.abi.datatypes.Address;
24 | import org.fisco.bcos.sdk.utils.Numeric;
25 |
26 | import java.math.BigInteger;
27 | import java.util.ArrayList;
28 | import java.util.List;
29 |
30 | /**
31 | * TransactionRecipt
32 | *
33 | * @Description: TransactionReceipt
34 | * @author maojiayu
35 | * @data Sep 25, 2019 10:36:21 AM
36 | *
37 | */
38 | @Data
39 | @EqualsAndHashCode
40 | @Accessors(chain = true)
41 | public class TransactionReceipt {
42 | private String stateRoot;
43 | private BigInteger gasUsed;
44 | private String contractAddress;
45 | private String logsBloom;
46 | private long status;
47 | private String output;
48 | private List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.stash.rlp;
15 |
16 |
17 |
18 | import org.fisco.bcos.sdk.utils.Hex;
19 |
20 | import java.io.Serializable;
21 | import java.util.Arrays;
22 |
23 |
24 | public class ByteArrayWrapper implements Comparable Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.stash.rlp;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 |
19 | import static org.bouncycastle.util.encoders.Hex.encode;
20 |
21 |
22 | public class CompactEncoder {
23 | private final static Map Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.stash.rlp;
15 |
16 | import java.io.Serializable;
17 |
18 | @SuppressWarnings("serial")
19 | public class DecodeResult implements Serializable {
20 |
21 | private int position;
22 | private Object decodedObject;
23 |
24 | public DecodeResult(int pos, Object decoded) {
25 | this.position = pos;
26 | this.decodedObject = decoded;
27 | }
28 |
29 | public int getPos() {
30 | return position;
31 | }
32 |
33 | public Object getDecoded() {
34 | return decodedObject;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/stash/rlp/RLPElement.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.stash.rlp;
15 |
16 | import java.io.Serializable;
17 |
18 | /**
19 | * Wrapper class for decoded elements from an RLP encoded byte array.
20 | *
21 | * @author Roman Mandeleil
22 | * @since 01.04.2014
23 | */
24 | public interface RLPElement extends Serializable {
25 |
26 | byte[] getRLPData();
27 | }
28 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/stash/rlp/RLPItem.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.stash.rlp;
15 |
16 | import lombok.Data;
17 |
18 |
19 | /**
20 | * RLPItem
21 | *
22 | * @Description: RLPItem
23 | * @author maojiayu
24 | * @data Sep 25, 2019 4:01:51 PM
25 | *
26 | */
27 | @Data
28 | public class RLPItem implements RLPElement {
29 |
30 | private static final long serialVersionUID = 7867984796230853830L;
31 | private final byte[] rlpData;
32 |
33 | public RLPItem(byte[] rlpData) {
34 | this.rlpData = rlpData;
35 | }
36 |
37 | public byte[] getRLPData() {
38 | if (rlpData.length == 0)
39 | return null;
40 | return rlpData;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/stash/rlp/RLPList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.stash.rlp;
15 |
16 | import lombok.Data;
17 | import lombok.EqualsAndHashCode;
18 | import org.fisco.bcos.sdk.utils.Numeric;
19 |
20 | import java.util.ArrayList;
21 | import java.util.List;
22 |
23 | /**
24 | * RLPList
25 | *
26 | * @Description: RLPList
27 | * @author maojiayu
28 | * @data Sep 4, 2019 4:21:50 PM
29 | *
30 | */
31 | @Data
32 | @EqualsAndHashCode(callSuper=false)
33 | public class RLPList extends ArrayList Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.tools;
15 |
16 | import org.fisco.bcos.sdk.abi.datatypes.Address;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 | import java.util.stream.Collectors;
21 |
22 |
23 | /**
24 | * AddressListUtils
25 | *
26 | * @Description: AddressListUtils
27 | * @author maojiayu
28 | * @data Dec 28, 2018 6:13:58 PM
29 | *
30 | */
31 | public class AddressListUtils {
32 |
33 | public static List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.tools;
15 |
16 | import cn.hutool.core.convert.Convert;
17 |
18 | import java.math.BigInteger;
19 |
20 | /**
21 | * BigIntegerUtils
22 | *
23 | * @Description: BigIntegerUtils
24 | * @author maojiayu
25 | * @data Dec 18, 2018 10:55:41 AM
26 | *
27 | */
28 | public class BigIntegerUtils {
29 |
30 | public static long toLong(BigInteger bi) {
31 | return bi.longValue();
32 | }
33 |
34 | public static long toLong(Object obj) {
35 | return Convert.toLong(obj);
36 | }
37 |
38 |
39 | public static int toInteger(BigInteger bi) {
40 | return bi.intValue();
41 | }
42 |
43 | public static int toInteger(Object obj) {
44 | BigInteger bi = (BigInteger) obj;
45 | return bi.intValue();
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/tools/BoolUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.tools;
15 |
16 | /**
17 | * BoolUtils
18 | *
19 | * @Description: BoolUtils
20 | * @author maojiayu
21 | * @data Mar 12, 2019 3:14:31 PM
22 | *
23 | */
24 | public class BoolUtils {
25 |
26 | public static boolean toBoolean(Boolean bool) {
27 | return bool.booleanValue();
28 | }
29 |
30 | public static boolean toBoolean(Object obj) {
31 | Boolean bool = (Boolean) obj;
32 | return bool.booleanValue();
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/tools/ClientUtil.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.common.tools;
2 |
3 | import com.google.common.collect.Maps;
4 | import com.webank.blockchain.data.export.common.entity.ChainInfo;
5 | import org.apache.commons.lang3.StringUtils;
6 | import org.fisco.bcos.sdk.BcosSDK;
7 | import org.fisco.bcos.sdk.client.Client;
8 | import org.fisco.bcos.sdk.config.ConfigOption;
9 | import org.fisco.bcos.sdk.config.exceptions.ConfigException;
10 | import org.fisco.bcos.sdk.config.model.ConfigProperty;
11 | import org.fisco.bcos.sdk.crypto.keypair.CryptoKeyPair;
12 |
13 | import java.util.Arrays;
14 | import java.util.List;
15 | import java.util.Map;
16 |
17 | /**
18 | * @author wesleywang
19 | * @Description:
20 | * @date 2020/12/17
21 | */
22 | public class ClientUtil {
23 |
24 | public static CryptoKeyPair cryptoKeyPair(ChainInfo chainInfo) throws ConfigException {
25 | Client client = getClient(chainInfo);
26 | return client.getCryptoSuite().createKeyPair();
27 | }
28 |
29 | public static Client getClient(ChainInfo chainInfo) throws ConfigException {
30 | BcosSDK sdk = getSDK(chainInfo);
31 | return sdk.getClient(chainInfo.getGroupId());
32 | }
33 |
34 | public static BcosSDK getSDK(ChainInfo chainInfo) throws ConfigException {
35 | ConfigProperty configProperty = new ConfigProperty();
36 | setPeers(configProperty,chainInfo);
37 | setCertPath(configProperty,chainInfo);
38 | ConfigOption option = new ConfigOption(configProperty);
39 | return new BcosSDK(option);
40 | }
41 |
42 | public static void setPeers(ConfigProperty configProperty, ChainInfo chainInfo) {
43 | String[] nodes = StringUtils.split(chainInfo.getNodeStr(), ";");
44 | List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.tools;
15 |
16 | import cn.hutool.core.date.DateUtil;
17 | import cn.hutool.core.util.HexUtil;
18 | import org.apache.commons.lang3.StringUtils;
19 |
20 | import java.util.Date;
21 |
22 | /**
23 | * DateUtils
24 | *
25 | * @Description: DateUtils
26 | * @author maojiayu
27 | * @data Oct 22, 2020 7:54:07 PM
28 | *
29 | */
30 | public class DateUtils {
31 |
32 | public static Date hexStrToDate(String hexString) {
33 | if (StringUtils.startsWithIgnoreCase(hexString, "0x")) {
34 | hexString = StringUtils.substring(hexString, 2);
35 | }
36 | return DateUtil.date(HexUtil.toBigInteger(hexString).longValue());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/tools/JacksonException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.tools;
15 |
16 | /**
17 | * JacksonException
18 | *
19 | * @Description: JacksonException
20 | * @author maojiayu
21 | * @data Dec 28, 2018 3:45:52 PM
22 | *
23 | */
24 | public class JacksonException extends RuntimeException {
25 |
26 | private static final long serialVersionUID = -3313868940376241665L;
27 |
28 | public JacksonException() {
29 | super();
30 | }
31 |
32 | public JacksonException(String message, Throwable cause) {
33 | super(message, cause);
34 | }
35 |
36 | public JacksonException(String message) {
37 | super(message);
38 | }
39 |
40 | public JacksonException(Throwable cause) {
41 | super(cause);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/tools/MessageLoader.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.tools;
15 |
16 | import lombok.extern.slf4j.Slf4j;
17 |
18 | import java.io.IOException;
19 | import java.io.InputStream;
20 | import java.util.Properties;
21 |
22 |
23 | /**
24 | * Load error messages defined in config.
25 | *
26 | * @author maojiayu
27 | * @data Dec 28, 2018 5:17:30 PM
28 | *
29 | */
30 | @Slf4j
31 | public class MessageLoader {
32 | private static Properties properties = new Properties();
33 |
34 | static {
35 | InputStream is = MessageLoader.class.getClassLoader().getResourceAsStream("error.properties");
36 | if (is != null) {
37 | try {
38 | properties.load(is);
39 | } catch (IOException e) {
40 | log.error("", e);
41 | throw new RuntimeException(e);
42 | }
43 | } else {
44 | throw new RuntimeException("error.properties not found");
45 | }
46 | }
47 |
48 | public static String getMessage(String name) {
49 | return properties.getProperty(name, null);
50 | }
51 |
52 | public static String getMessage(String name, Object...args) {
53 | String template = properties.getProperty(name, null);
54 | return String.format(template, args);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-common/src/main/java/com/webank/blockchain/data/export/common/tools/NameValueVO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.tools;
15 |
16 | import lombok.AllArgsConstructor;
17 | import lombok.Data;
18 | import lombok.NoArgsConstructor;
19 | import lombok.experimental.Accessors;
20 |
21 | /**
22 | * NameValueVO: common vo.
23 | *
24 | * @author maojiayu
25 | * @data Dec 28, 2018 3:54:40 PM
26 | *
27 | */
28 | @Data
29 | @NoArgsConstructor
30 | @AllArgsConstructor
31 | @Accessors(chain = true)
32 | public class NameValueVO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.vo;
15 |
16 | import lombok.AllArgsConstructor;
17 | import lombok.Data;
18 | import lombok.EqualsAndHashCode;
19 | import lombok.NoArgsConstructor;
20 | import lombok.experimental.Accessors;
21 |
22 |
23 | /**
24 | * CommonDataResponse
25 | *
26 | * @Description: CommonDataResponse
27 | * @author maojiayu
28 | * @data Dec 28, 2018 6:01:15 PM
29 | *
30 | */
31 | @Data
32 | @NoArgsConstructor
33 | @AllArgsConstructor
34 | @Accessors(chain = true)
35 | @EqualsAndHashCode(callSuper = true)
36 | public class CommonDataResponse Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.vo;
15 |
16 | import com.fasterxml.jackson.annotation.JsonInclude;
17 | import com.webank.blockchain.data.export.common.constants.StatusCode;
18 | import lombok.AllArgsConstructor;
19 | import lombok.Data;
20 | import lombok.NoArgsConstructor;
21 | import lombok.experimental.Accessors;
22 |
23 | import java.util.Map;
24 |
25 | /**
26 | * CommonResponse
27 | *
28 | * @author maojiayu
29 | * @data Dec 28, 2018 6:02:57 PM
30 | *
31 | */
32 | @Data
33 | @NoArgsConstructor
34 | @AllArgsConstructor
35 | @Accessors(chain = true)
36 | @JsonInclude(JsonInclude.Include.NON_NULL)
37 | public class CommonResponse {
38 | protected int status = 0;
39 | protected Msg msg;
40 | public static CommonResponse SUCCESS = new CommonResponse();
41 | public static CommonResponse UNLOGIN = new CommonResponse(StatusCode.SESSION_EXPIRED, "user not login");
42 | public static CommonResponse UNAUTH = new CommonResponse(StatusCode.UNAUTH, "user no auth");
43 | public static CommonResponse SYSERROR = new CommonResponse(StatusCode.EXECUTE_ERROR, "execute error");
44 | public static CommonResponse NOBLOCK = new CommonResponse(StatusCode.PARAMETER_ERROR, "no block data");
45 |
46 | public CommonResponse(int status, String error) {
47 | this.status = status;
48 | this.msg = new Msg().setGlobal(error);
49 | }
50 |
51 | @Data
52 | @Accessors(chain = true)
53 | @JsonInclude(JsonInclude.Include.NON_NULL)
54 | public static class Msg {
55 | private String global;
56 | private Map Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.common.vo;
15 |
16 | import com.webank.blockchain.data.export.common.constants.StatusCode;
17 | import lombok.Data;
18 | import lombok.EqualsAndHashCode;
19 | import lombok.experimental.Accessors;
20 |
21 | import java.util.HashMap;
22 |
23 | /**
24 | * ValidErrorResponse, wrap the basic valid error usage of MVC.
25 | *
26 | * @author maojiayu
27 | * @data Dec 28, 2018 6:05:45 PM
28 | *
29 | */
30 | @Data
31 | @Accessors(chain = true)
32 | @EqualsAndHashCode(callSuper = true)
33 | public class ValidErrorResponse extends CommonResponse {
34 | public ValidErrorResponse() {
35 | this.status = StatusCode.PARAMETER_ERROR;
36 | msg = new Msg().setGlobal("").setFields(new HashMap<>());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-core/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | /bin/
4 | bin/*
5 | #config/*
6 | /.gradle/
7 |
8 |
9 |
10 | ### STS ###
11 | .apt_generated
12 | .classpath
13 | .factorypath
14 | .project
15 | .settings
16 | .springBeans
17 | .sts4-cache
18 |
19 | ### IntelliJ IDEA ###
20 | .idea
21 | *.iws
22 | *.iml
23 | *.ipr
24 |
25 | ### NetBeans ###
26 | /nbproject/private/
27 | /build/
28 | /nbbuild/
29 | /dist/
30 | /nbdist/
31 | /.nb-gradle/
32 |
33 | src/main/scripts
34 | src/main/resources
35 |
36 | ## contracts ##
37 | src/main/java/com/webank/bcosbee/generated
38 | src/main/java/com/webank/blockchain.data.export/core/generated
39 | src/main/java/org
40 | my.log*
41 | *.log
42 |
43 | src/test/java/com/webank/webasebee/contract/
44 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-core/build.gradle:
--------------------------------------------------------------------------------
1 | clean {
2 | println "delete ${projectDir}/dist"
3 | delete "${projectDir}/dist"
4 | }
5 | dependencies {
6 | implementation project(':WeBankBlockchain-Data-Export-parser')
7 | implementation project(':WeBankBlockchain-Data-Export-common')
8 | implementation project(':WeBankBlockchain-Data-Export-db')
9 | }
10 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-core/src/main/java/com/webank/blockchain/data/export/api/DataExportService.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.api;
2 |
3 | import java.util.Map;
4 | import java.util.stream.Collectors;
5 |
6 | import com.webank.blockchain.data.export.common.entity.BlockDataSource;
7 | import com.webank.blockchain.data.export.common.entity.ChainInfo;
8 | import com.webank.blockchain.data.export.common.entity.ContractInfo;
9 | import com.webank.blockchain.data.export.common.entity.DataExportContext;
10 | import com.webank.blockchain.data.export.common.entity.ExportConfig;
11 | import com.webank.blockchain.data.export.common.entity.ExportDataSource;
12 | import com.webank.blockchain.data.export.common.entity.StashInfo;
13 | import com.webank.blockchain.data.export.task.DataExportExecutor;
14 |
15 | import cn.hutool.core.collection.CollectionUtil;
16 |
17 | /**
18 | * @author wesleywang
19 | * @Description:
20 | * @date 2020/12/16
21 | */
22 | public class DataExportService {
23 |
24 | public static DataExportExecutor create(ExportDataSource dataSource, BlockDataSource blockDataSource, ExportConfig config) throws Exception {
25 | return new DataExportExecutor(buildContext(dataSource, blockDataSource, config));
26 | }
27 |
28 | public static void start(DataExportExecutor exportExecutor) {
29 | exportExecutor.start();
30 | }
31 |
32 | public static void stop(DataExportExecutor exportExecutor) {
33 | exportExecutor.stop();
34 | }
35 |
36 | private static DataExportContext buildContext(ExportDataSource dataSource, BlockDataSource blockDataSource, ExportConfig config) throws Exception {
37 | DataExportContext context = new DataExportContext();
38 | if (CollectionUtil.isNotEmpty(config.getContractInfoList())) {
39 | Map Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.service;
15 |
16 | import org.fisco.bcos.sdk.client.protocol.response.BcosBlock.Block;
17 |
18 | /**
19 | * BlockAsyncService
20 | *
21 | * @Description: BlockAsyncService
22 | * @author maojiayu
23 | * @data Jun 27, 2019 3:54:56 PM
24 | *
25 | */
26 | public class BlockAsyncService {
27 |
28 | public static void handleSingleBlock(Block b, long total) {
29 | BlockDepotService.process(b, total);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-core/src/main/java/com/webank/blockchain/data/export/service/BlockCrawlService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.service;
15 |
16 | import com.google.common.base.Stopwatch;
17 | import com.webank.blockchain.data.export.common.bo.data.BlockInfoBO;
18 | import com.webank.blockchain.data.export.common.entity.ExportConstant;
19 | import com.webank.blockchain.data.export.parser.facade.ParseFacade;
20 | import lombok.extern.slf4j.Slf4j;
21 | import org.fisco.bcos.sdk.client.protocol.response.BcosBlock.Block;
22 |
23 | import java.io.IOException;
24 | import java.math.BigInteger;
25 | import java.util.concurrent.TimeUnit;
26 |
27 | /**
28 | * BlockCrawlService
29 | *
30 | * @Description: BlockCrawlService
31 | * @author maojiayu
32 | * @data 2019-07-05 16:06:12
33 | *
34 | */
35 | @Slf4j
36 | public class BlockCrawlService {
37 | /**
38 | * parse a Block to BlockInfoBO by using parser tools.
39 | *
40 | * @param blockHeight
41 | * @return BlockInfoBO, which include all the structs of a block containing contract info.
42 | * @throws IOException
43 | */
44 | public static BlockInfoBO parse(long blockHeight) throws IOException {
45 | BigInteger bigBlockHeight = new BigInteger(Long.toString(blockHeight));
46 | Block block = getBlock(bigBlockHeight);
47 | return parse(block);
48 | }
49 |
50 | public static BlockInfoBO parse(Block block) throws IOException {
51 | Stopwatch st1 = Stopwatch.createStarted();
52 | BlockInfoBO blockInfo = ParseFacade.parse(block);
53 | log.info("bcosCrawlerMap block:{} succeed, bcosCrawlerMap.handleReceipt useTime: {}",
54 | block.getNumber().longValue(), st1.stop().elapsed(TimeUnit.MILLISECONDS));
55 | return blockInfo;
56 | }
57 |
58 | public static Block getBlock(BigInteger blockHeightNumber) throws IOException {
59 | Stopwatch stopwatch = Stopwatch.createStarted();
60 | log.debug("get block number: {}", blockHeightNumber);
61 | Block block = ExportConstant.getCurrentContext().getClient()
62 | .getBlockByNumber(blockHeightNumber);
63 | Stopwatch st1 = stopwatch.stop();
64 | log.info("get block:{} succeed, eth.getBlock useTime: {}", blockHeightNumber,
65 | st1.elapsed(TimeUnit.MILLISECONDS));
66 | return block;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-core/src/main/java/com/webank/blockchain/data/export/service/BlockListenerService.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.service;
2 |
3 | import com.webank.blockchain.data.export.common.bo.data.*;
4 | import com.webank.blockchain.data.export.common.entity.ExportConstant;
5 | import com.webank.blockchain.data.export.common.subscribe.TopicRegistry;
6 | import com.webank.blockchain.data.export.db.entity.TxRawData;
7 |
8 | /**
9 | * @author aaronchu
10 | * @Description
11 | * @date 2021/08/31
12 | */
13 | public class BlockListenerService {
14 |
15 | public static void onBlock(BlockInfoBO blockInfoBO){
16 | TopicRegistry subscribers = ExportConstant.getCurrentContext().getTopicRegistry();
17 | if(subscribers == null) return;
18 | if(subscribers.getBlockTopic() != null){
19 | subscribers.getBlockTopic().publish(blockInfoBO, null);
20 | }
21 |
22 | if(subscribers.getTxTopic() != null && blockInfoBO.getTxRawDataBOList() != null){
23 | for(TxRawDataBO rawData: blockInfoBO.getTxRawDataBOList()){
24 | subscribers.getTxTopic().publish(rawData, blockInfoBO);
25 | }
26 | }
27 |
28 |
29 | if(subscribers.getTxReceiptTopic() != null && blockInfoBO.getTxReceiptRawDataBOList() != null){
30 | for(TxReceiptRawDataBO rawData: blockInfoBO.getTxReceiptRawDataBOList()){
31 | subscribers.getTxReceiptTopic().publish(rawData, blockInfoBO);
32 | }
33 | }
34 |
35 | if(subscribers.getMethodTopic() != null && blockInfoBO.getMethodInfoList() != null){
36 | for(MethodBO methodBO:blockInfoBO.getMethodInfoList()){
37 | subscribers.getMethodTopic().publish(methodBO, blockInfoBO);
38 | }
39 | }
40 |
41 | if(subscribers.getEventTopic() != null && blockInfoBO.getEventInfoList() != null){
42 | for(EventBO eventBO:blockInfoBO.getEventInfoList()){
43 | subscribers.getEventTopic().publish(eventBO, blockInfoBO);
44 | }
45 | }
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-core/src/main/java/com/webank/blockchain/data/export/service/BlockStoreService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.service;
15 |
16 | import cn.hutool.core.collection.CollectionUtil;
17 | import com.webank.blockchain.data.export.common.bo.data.BlockInfoBO;
18 | import com.webank.blockchain.data.export.db.service.DataStoreService;
19 | import com.webank.blockchain.data.export.task.DataPersistenceManager;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | * BlockStoreService
25 | *
26 | * @Description: BlockStoreService
27 | * @author maojiayu
28 | * @data Jul 5, 2019 4:09:23 PM
29 | *
30 | */
31 | public class BlockStoreService {
32 |
33 | public static void store(BlockInfoBO blockInfo) {
34 | List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.service;
15 |
16 | import com.webank.blockchain.data.export.task.DataPersistenceManager;
17 |
18 | /**
19 | * RollBackService, rollback
20 | *
21 | * @Description: RollBackService
22 | * @author maojiayu
23 | * @data 2018-12-27 15:59:41
24 | *
25 | */
26 | public class RollBackService {
27 |
28 | /**
29 | * Do rollback, including events, methods, accounts, and details.
30 | *
31 | * @param
32 | */
33 | public static void rollback(long start, long end) {
34 | DataPersistenceManager.getCurrentManager().getRollbackOneInterfaceList()
35 | .forEach(v -> {
36 | v.rollback(start, end);
37 | });
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-core/src/main/java/com/webank/blockchain/data/export/tools/ElasticJobUtil.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.tools;
2 |
3 | import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
4 | import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
5 | import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration;
6 | import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
7 |
8 | /**
9 | * @author wesleywang
10 | * @Description:
11 | * @date 2020/12/22
12 | */
13 | public class ElasticJobUtil {
14 |
15 | public static CoordinatorRegistryCenter createRegistryCenter(String zookeeperServiceLists, String zookeeperNamespace) {
16 | CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration(
17 | zookeeperServiceLists,zookeeperNamespace));
18 | regCenter.init();
19 | return regCenter;
20 | }
21 |
22 | public static JobConfiguration createJobConfiguration(String jobName, String cron,
23 | int shardingCount, String shardingItemParameters) {
24 | return JobConfiguration.newBuilder(jobName, shardingCount)
25 | .cron(cron).shardingItemParameters(shardingItemParameters).build();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | /bin/
4 | bin/*
5 | config/*
6 | /.gradle/
7 |
8 |
9 |
10 | ### STS ###
11 | .apt_generated
12 | .classpath
13 | .factorypath
14 | .project
15 | .settings
16 | .springBeans
17 | .sts4-cache
18 |
19 | ### IntelliJ IDEA ###
20 | .idea
21 | *.iws
22 | *.iml
23 | *.ipr
24 |
25 | ### NetBeans ###
26 | /nbproject/private/
27 | /build/
28 | /nbbuild/
29 | /dist/
30 | /nbdist/
31 | /.nb-gradle/
32 |
33 | src/main/scripts
34 | src/main/resources
35 |
36 | ## contracts ##
37 | src/main/java/com/webank/bcosbee/generated
38 | src/main/java/com/webank/webasebee/db/generated
39 | src/main/java/org
40 | my.log*
41 | *.log
42 |
43 | src/test/java/com/webank/webasebee/contract/
44 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/build.gradle:
--------------------------------------------------------------------------------
1 | clean {
2 | println "delete ${projectDir}/dist"
3 | delete "${projectDir}/dist"
4 | }
5 |
6 | dependencies {
7 | implementation project(':WeBankBlockchain-Data-Export-common')
8 | implementation project(':WeBankBlockchain-Data-Export-parser')
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/dao/BlockDetailInfoDAO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.dao;
15 |
16 | import com.webank.blockchain.data.export.common.bo.data.BlockDetailInfoBO;
17 | import com.webank.blockchain.data.export.common.bo.data.BlockInfoBO;
18 | import com.webank.blockchain.data.export.db.entity.BlockDetailInfo;
19 | import com.webank.blockchain.data.export.db.repository.BlockDetailInfoRepository;
20 |
21 | import cn.hutool.core.bean.BeanUtil;
22 | import lombok.AllArgsConstructor;
23 |
24 | /**
25 | * BlockDetailInfoDAO
26 | *
27 | * @author maojiayu
28 | * @data Dec 12, 2018 2:45:13 PM
29 | *
30 | */
31 | @AllArgsConstructor
32 | public class BlockDetailInfoDAO implements SaveInterface Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.dao;
15 |
16 | import cn.hutool.core.bean.BeanUtil;
17 | import com.webank.blockchain.data.export.common.bo.data.BlockInfoBO;
18 | import com.webank.blockchain.data.export.common.bo.data.BlockRawDataBO;
19 | import com.webank.blockchain.data.export.db.entity.BlockRawData;
20 | import com.webank.blockchain.data.export.db.repository.BlockRawDataRepository;
21 | import lombok.AllArgsConstructor;
22 |
23 | /**
24 | * @author wesleywang
25 | * @Description:
26 | * @date 2020/10/23
27 | */
28 | @AllArgsConstructor
29 | public class BlockRawDataDAO implements SaveInterface Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.dao;
15 |
16 | import cn.hutool.core.bean.BeanUtil;
17 | import com.webank.blockchain.data.export.common.bo.data.ContractInfoBO;
18 | import com.webank.blockchain.data.export.db.entity.ContractInfo;
19 | import com.webank.blockchain.data.export.db.repository.ContractInfoRepository;
20 | import lombok.AllArgsConstructor;
21 |
22 | /**
23 | * @author wesleywang
24 | * @Description:
25 | * @date 2020/10/26
26 | */
27 | @AllArgsConstructor
28 | public class ContractInfoDAO implements SaveInterface Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.dao;
15 |
16 | import cn.hutool.core.bean.BeanUtil;
17 | import com.webank.blockchain.data.export.common.bo.data.BlockInfoBO;
18 | import com.webank.blockchain.data.export.common.bo.data.DeployedAccountInfoBO;
19 | import com.webank.blockchain.data.export.db.entity.DeployedAccountInfo;
20 | import com.webank.blockchain.data.export.db.repository.DeployedAccountInfoRepository;
21 | import lombok.AllArgsConstructor;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | * @author wesleywang
27 | * @Description:
28 | * @date 2020/10/26
29 | */
30 | @AllArgsConstructor
31 | public class DeployedAccountInfoDAO implements SaveInterface Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.dao;
15 |
16 | /**
17 | * SaveInterface declares a interface which must be saved.
18 | *
19 | * @author maojiayu
20 | * @data Dec 13, 2018 8:27:46 PM
21 | *
22 | */
23 | public interface SaveInterface Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.dao;
15 |
16 | import cn.hutool.core.bean.BeanUtil;
17 | import com.webank.blockchain.data.export.common.bo.data.BlockInfoBO;
18 | import com.webank.blockchain.data.export.common.bo.data.TxRawDataBO;
19 | import com.webank.blockchain.data.export.db.entity.TxRawData;
20 | import com.webank.blockchain.data.export.db.repository.TxRawDataRepository;
21 | import lombok.AllArgsConstructor;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | * @author wesleywang
27 | * @Description:
28 | * @date 2020/10/26
29 | */
30 | @AllArgsConstructor
31 | public class TxRawDataDAO implements SaveInterface Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.dao;
15 |
16 | import cn.hutool.core.bean.BeanUtil;
17 | import com.webank.blockchain.data.export.common.bo.data.BlockInfoBO;
18 | import com.webank.blockchain.data.export.common.bo.data.TxReceiptRawDataBO;
19 | import com.webank.blockchain.data.export.db.entity.TxReceiptRawData;
20 | import com.webank.blockchain.data.export.db.repository.TxReceiptRawDataRepository;
21 | import lombok.AllArgsConstructor;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | * @author wesleywang
27 | * @Description:
28 | * @date 2020/10/26
29 | */
30 | @AllArgsConstructor
31 | public class TxReceiptRawDataDAO implements SaveInterface Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.entity;
15 |
16 | import lombok.Data;
17 | import lombok.EqualsAndHashCode;
18 | import lombok.ToString;
19 | import lombok.experimental.Accessors;
20 |
21 | import java.util.Date;
22 |
23 | /**
24 | * BlockDetailInfo entity storage of block detail info.
25 | *
26 | * @Description: BlockDetailInfo
27 | * @author graysonzhang
28 | * @data 2018-11-14 17:45:16
29 | *
30 | */
31 | @SuppressWarnings("serial")
32 | @Data
33 | @Accessors(chain = true)
34 | @ToString(callSuper = true)
35 | @EqualsAndHashCode(callSuper = true)
36 | public class BlockDetailInfo extends IdEntity {
37 |
38 | /** @Fields blockHeight : block height */
39 | private long blockHeight;
40 |
41 | /** @Fields blockHash : block hash */
42 | private String blockHash;
43 |
44 | /** @Fields txCount : transaction's count in block */
45 | private short txCount;
46 |
47 | /** @Fields blockTimeStamp : block timestamp */
48 | private Date blockTimeStamp;
49 |
50 | /** @Fields status : block process status */
51 | private short status;
52 |
53 | /** @Fields updatetime : depot update time */
54 | protected Date depotUpdatetime = new Date();
55 |
56 | public enum Status {
57 | TODO, COMPLETED
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/entity/BlockRawData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.entity;
15 |
16 | import lombok.Data;
17 | import lombok.EqualsAndHashCode;
18 | import lombok.ToString;
19 | import lombok.experimental.Accessors;
20 |
21 | import java.util.Date;
22 |
23 | /**
24 | * @author wesleywang
25 | * @Description:
26 | * @date 2020/10/23
27 | */
28 | @Data
29 | @Accessors(chain = true)
30 | @ToString(callSuper = true)
31 | @EqualsAndHashCode(callSuper = true)
32 | public class BlockRawData extends IdEntity {
33 | private static final long serialVersionUID = -6636726869135248569L;
34 |
35 | /** @Fields blockHash : block hash */
36 | private String blockHash;
37 |
38 | /** @Fields blockHeight : block height */
39 | private long blockHeight;
40 |
41 | /** @Fields blockTimeStamp : block timestamp */
42 | private Date blockTimeStamp;
43 |
44 | private String parentHash;
45 |
46 | private String logsBloom;
47 |
48 | private String transactionsRoot;
49 |
50 | private String receiptsRoot;
51 |
52 | private String dbHash;
53 |
54 | private String stateRoot;
55 |
56 | private String sealer;
57 |
58 | private String sealerList;
59 |
60 | private String extraData;
61 |
62 | private String gasLimit;
63 |
64 | private String gasUsed;
65 |
66 | private String signatureList;
67 |
68 | private String transactionList;
69 |
70 | /** @Fields updatetime : depot update time */
71 | protected Date depotUpdatetime = new Date();
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/entity/BlockTaskPool.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.entity;
15 |
16 | import com.fasterxml.jackson.annotation.JsonInclude;
17 | import lombok.Data;
18 | import lombok.EqualsAndHashCode;
19 | import lombok.experimental.Accessors;
20 |
21 | import java.util.Date;
22 |
23 | /**
24 | * BlockTaskPool
25 | *
26 | * @Description: BlockTaskPool
27 | * @author maojiayu
28 | * @data Apr 1, 2019 3:04:00 PM
29 | *
30 | */
31 | @Data
32 | @Accessors(chain = true)
33 | @EqualsAndHashCode(callSuper = true)
34 | @JsonInclude(JsonInclude.Include.NON_NULL)
35 | public class BlockTaskPool extends IdEntity {
36 |
37 | private static final long serialVersionUID = 5987912520917085396L;
38 |
39 | private long blockHeight;
40 |
41 | /** @Fields syncStatus : sync status of transactions */
42 | private short syncStatus;
43 |
44 | /** @Fields certainty : certainty of fork check */
45 | private short certainty;
46 |
47 | private short handleItem = 0;
48 |
49 | /** @Fields updatetime : update time */
50 | protected Date depotUpdatetime;
51 | }
52 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/entity/BlockTxDetailInfo.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.entity;
15 |
16 | import com.fasterxml.jackson.annotation.JsonInclude;
17 | import lombok.Data;
18 | import lombok.EqualsAndHashCode;
19 | import lombok.ToString;
20 | import lombok.experimental.Accessors;
21 |
22 | import java.util.Date;
23 |
24 | /**
25 | * BlockTxDetailInfo
26 | *
27 | * @Description: BlockTxDetailInfo
28 | * @author graysonzhang
29 | * @data 2018-12-20 14:38:18
30 | *
31 | */
32 | @SuppressWarnings("serial")
33 | @Data
34 | @Accessors(chain = true)
35 | @ToString(callSuper = true)
36 | @EqualsAndHashCode(callSuper = true)
37 | @JsonInclude(JsonInclude.Include.NON_NULL)
38 | public class BlockTxDetailInfo extends IdEntity {
39 |
40 | /** @Fields blockHeight : block height */
41 | private long blockHeight;
42 |
43 | /** @Fields blockHash : block hash */
44 | private String blockHash;
45 |
46 | /** @Fields contractName : contract name */
47 | private String contractName;
48 |
49 | /** @Fields methodName : contract method name */
50 | private String methodName;
51 |
52 | /** @Fields txHash : transaction hash */
53 | private String txHash;
54 |
55 | /** @Fields txFrom : transaction' s from */
56 | private String txFrom;
57 |
58 | /** @Fields txTo : transaction's to */
59 | private String txTo;
60 |
61 | /** @Fields blockTimeStamp : block timestamp */
62 | private Date blockTimeStamp;
63 |
64 | /** @Fields updatetime : depot update time */
65 | protected Date depotUpdatetime = new Date();
66 | }
67 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/entity/ContractInfo.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.entity;
15 |
16 | import lombok.Data;
17 | import lombok.EqualsAndHashCode;
18 | import lombok.ToString;
19 | import lombok.experimental.Accessors;
20 |
21 | import java.util.Date;
22 |
23 | /**
24 | * @author wesleywang
25 | * @Description:
26 | * @date 2020/10/26
27 | */
28 | @EqualsAndHashCode(callSuper = true)
29 | @Data
30 | @Accessors(chain = true)
31 | @ToString(callSuper = true)
32 | public class ContractInfo extends IdEntity {
33 | private static final long serialVersionUID = 5724687955937639884L;
34 |
35 | protected String abiHash;
36 |
37 | private String contractABI;
38 |
39 | private String contractBinary;
40 |
41 | private short version = 1;
42 |
43 | private String contractName;
44 |
45 | /** @Fields updatetime : depot update time */
46 | protected Date depotUpdatetime = new Date();
47 | }
48 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/entity/DeployedAccountInfo.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.entity;
15 |
16 | import lombok.Data;
17 | import lombok.EqualsAndHashCode;
18 | import lombok.ToString;
19 | import lombok.experimental.Accessors;
20 |
21 | import java.util.Date;
22 |
23 | /**
24 | * @author wesleywang
25 | * @Description:
26 | * @date 2020/10/26
27 | */
28 | @Data
29 | @Accessors(chain = true)
30 | @ToString(callSuper = true)
31 | @EqualsAndHashCode(callSuper = true)
32 | public class DeployedAccountInfo extends IdEntity {
33 | /** @Fields serialVersionUID : TODO */
34 | private static final long serialVersionUID = 8671861939859734978L;
35 |
36 | /** @Fields contractName : contract name */
37 | private String contractName;
38 |
39 | /** @Fields contractAddress : contract address */
40 | private String contractAddress;
41 |
42 | /** @Fields blockHeight : block height */
43 | private long blockHeight;
44 |
45 | /** @Fields blockTimeStamp : block timestamp */
46 | private Date blockTimeStamp;
47 |
48 | private String abiHash;
49 |
50 | /** @Fields updatetime : depot update time */
51 | protected Date depotUpdatetime = new Date();
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/entity/IdEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.entity;
15 |
16 | import lombok.Data;
17 | import lombok.experimental.Accessors;
18 |
19 | import java.io.Serializable;
20 |
21 | /**
22 | * IdEntity
23 | *
24 | * @Description: IdEntity
25 | * @author maojiayu
26 | * @data Dec 28, 2018 6:05:11 PM
27 | *
28 | */
29 | @Data
30 | @Accessors(chain = true)
31 | public abstract class IdEntity implements Serializable {
32 |
33 | private static final long serialVersionUID = 5903397383140175895L;
34 | /** @Fields pkId : primary key */
35 | protected Long pkId;
36 | }
37 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/entity/TxRawData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.entity;
15 |
16 | import lombok.Data;
17 | import lombok.EqualsAndHashCode;
18 | import lombok.ToString;
19 | import lombok.experimental.Accessors;
20 |
21 | import java.util.Date;
22 |
23 | /**
24 | * @author wesleywang
25 | * @Description:
26 | * @date 2020/10/23
27 | */
28 | @Data
29 | @Accessors(chain = true)
30 | @ToString(callSuper = true)
31 | @EqualsAndHashCode(callSuper = true)
32 | public class TxRawData extends IdEntity {
33 | private static final long serialVersionUID = -2666867877669597503L;
34 |
35 | /** @Fields blockHeight : block height */
36 | private long blockHeight;
37 |
38 | /** @Fields blockHash : block hash */
39 | private String blockHash;
40 |
41 | /** @Fields txHash : transaction hash */
42 | private String txHash;
43 |
44 | private String txIndex;
45 |
46 | /** @Fields blockTimeStamp : block timestamp */
47 | private Date blockTimeStamp;
48 |
49 | private String from;
50 |
51 | private String gas;
52 |
53 | private String input;
54 |
55 | private String nonce;
56 |
57 | private String to;
58 |
59 | private String value;
60 |
61 | private String gasPrice;
62 |
63 | /** @Fields updatetime : depot update time */
64 | protected Date depotUpdatetime = new Date();
65 |
66 |
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/entity/TxReceiptRawData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.entity;
15 |
16 | import lombok.Data;
17 | import lombok.EqualsAndHashCode;
18 | import lombok.ToString;
19 | import lombok.experimental.Accessors;
20 |
21 | import java.util.Date;
22 |
23 | /**
24 | * @author wesleywang
25 | * @Description:
26 | * @date 2020/10/23
27 | */
28 | @Data
29 | @Accessors(chain = true)
30 | @ToString(callSuper = true)
31 | @EqualsAndHashCode(callSuper = true)
32 | public class TxReceiptRawData extends IdEntity {
33 | private static final long serialVersionUID = 2319335707392149645L;
34 |
35 | /** @Fields blockHeight : block height */
36 | private long blockHeight;
37 |
38 | /** @Fields blockHash : block hash */
39 | private String blockHash;
40 |
41 | /** @Fields txHash : transaction hash */
42 | private String txHash;
43 |
44 | /** @Fields blockTimeStamp : block timestamp */
45 | private Date blockTimeStamp;
46 |
47 | private String txIndex;
48 |
49 | private String root;
50 |
51 | private String from;
52 |
53 | private String to;
54 |
55 | private String gasUsed;
56 |
57 | private String contractAddress;
58 |
59 | private String logs;
60 |
61 | private String logsBloom;
62 |
63 | private String status;
64 |
65 | private String input;
66 |
67 | private String output;
68 |
69 | private String txProof;
70 |
71 | private String receiptProof;
72 |
73 | private String message;
74 |
75 | /** @Fields updatetime : depot update time */
76 | protected Date depotUpdatetime = new Date();
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/repository/BlockRawDataRepository.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.repository;
15 |
16 | import cn.hutool.db.DaoTemplate;
17 | import cn.hutool.db.Db;
18 | import cn.hutool.db.Entity;
19 | import com.webank.blockchain.data.export.common.entity.ExportConstant;
20 | import com.webank.blockchain.data.export.db.entity.BlockRawData;
21 | import lombok.AllArgsConstructor;
22 | import lombok.extern.slf4j.Slf4j;
23 |
24 | import java.sql.SQLException;
25 |
26 | /**
27 | * @author wesleywang
28 | * @Description:
29 | * @date 2020/10/23
30 | */
31 | @Slf4j
32 | @AllArgsConstructor
33 | public class BlockRawDataRepository implements RollbackInterface {
34 |
35 | private DaoTemplate blockRawDataDao;
36 |
37 | private final String tableName;
38 |
39 |
40 | public void rollback(long blockHeight){
41 | try {
42 | blockRawDataDao.del(Entity.create(tableName).set("block_height",">= " + blockHeight));
43 | } catch (SQLException e) {
44 | log.error(" BlockRawDataRepository rollback failed ", e);
45 | }
46 | }
47 |
48 | public void rollback(long startBlockHeight, long endBlockHeight){
49 | try {
50 | Db.use(ExportConstant.getCurrentContext().getDataSource()).execute(
51 | "delete from " + tableName +" where block_height >= ? and block_height< ?",startBlockHeight,endBlockHeight);
52 | } catch (SQLException e) {
53 | log.error(" BlockRawDataRepository rollback failed ", e);
54 | }
55 | }
56 |
57 |
58 | public void save(BlockRawData blockRawData) {
59 | try {
60 | Entity entity = Entity.parse(blockRawData,true,true);
61 | entity.setTableName(tableName);
62 | blockRawDataDao.addForGeneratedKey(entity);
63 | } catch (SQLException e) {
64 | log.error(" BlockRawDataRepository save failed ", e);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/repository/ContractInfoRepository.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.repository;
15 |
16 | import cn.hutool.db.DaoTemplate;
17 | import cn.hutool.db.Entity;
18 | import com.webank.blockchain.data.export.db.entity.ContractInfo;
19 | import com.webank.blockchain.data.export.db.tools.BeanUtils;
20 | import lombok.AllArgsConstructor;
21 | import lombok.extern.slf4j.Slf4j;
22 |
23 | import java.sql.SQLException;
24 |
25 | /**
26 | * @author wesleywang
27 | * @Description:
28 | * @date 2020/10/26
29 | */
30 | @Slf4j
31 | @AllArgsConstructor
32 | public class ContractInfoRepository {
33 |
34 | private DaoTemplate contractDao;
35 |
36 | private String tableName;
37 |
38 | public void save(ContractInfo contractInfo) {
39 | try {
40 | Entity entity = Entity.parse(contractInfo,true,true);
41 | entity.setTableName(tableName);
42 | contractDao.add(entity);
43 | } catch (SQLException e) {
44 | log.error("ContractInfoRepository save failed ", e);
45 | }
46 | }
47 |
48 | public ContractInfo findByAbiHash(String abiHash) {
49 | Entity entity = null;
50 | try {
51 | entity = contractDao.get("abi_hash",abiHash);
52 | } catch (SQLException e) {
53 | log.error(" BlockTaskPoolRepository findTopByOrderByBlockHeightDesc failed ", e);
54 | }
55 | if (entity == null){
56 | return null;
57 | }
58 | return BeanUtils.toBean(entity, ContractInfo.class);
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/repository/DeployedAccountInfoRepository.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.repository;
15 |
16 | import cn.hutool.db.DaoTemplate;
17 | import cn.hutool.db.Entity;
18 | import com.webank.blockchain.data.export.db.entity.DeployedAccountInfo;
19 | import lombok.AllArgsConstructor;
20 | import lombok.extern.slf4j.Slf4j;
21 |
22 | import java.sql.SQLException;
23 |
24 | /**
25 | * @author wesleywang
26 | * @Description:
27 | * @date 2020/10/26
28 | */
29 | @Slf4j
30 | @AllArgsConstructor
31 | public class DeployedAccountInfoRepository {
32 |
33 | private DaoTemplate deployedAccountInfoDao;
34 |
35 | private String tableName;
36 |
37 |
38 | public void save(DeployedAccountInfo deployedAccountInfo) {
39 | try {
40 | Entity entity = Entity.parse(deployedAccountInfo,true,true);
41 | entity.setTableName(tableName);
42 | deployedAccountInfoDao.addForGeneratedKey(entity);
43 | } catch (SQLException e) {
44 | log.error(" DeployedAccountInfoRepository save failed ", e);
45 | }
46 |
47 | }
48 | }
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/repository/RollbackInterface.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.repository;
15 |
16 | /**
17 | * RollbackOneInterface
18 | *
19 | * @Description: RollbackOneInterface
20 | * @author maojiayu
21 | * @data Dec 13, 2018 10:53:39 AM
22 | *
23 | */
24 | public interface RollbackInterface {
25 | /*
26 | * @see com.webank.blockchain.data.export.sys.db.repository.RollbackInterface#rollback(long)
27 | */
28 | void rollback(long blockHeight);
29 |
30 | /**
31 | * rollback from startBlockHeight to endBlockHeight, including startBlockHeight, but not including endBlockHeight.
32 | *
33 | * @param startBlockHeight
34 | * @param endBlockHeight
35 | */
36 | void rollback(long startBlockHeight, long endBlockHeight);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/repository/TxRawDataRepository.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.repository;
15 |
16 | import cn.hutool.db.DaoTemplate;
17 | import cn.hutool.db.Db;
18 | import cn.hutool.db.Entity;
19 | import com.webank.blockchain.data.export.common.entity.ExportConstant;
20 | import com.webank.blockchain.data.export.db.entity.TxRawData;
21 | import lombok.AllArgsConstructor;
22 | import lombok.extern.slf4j.Slf4j;
23 |
24 | import java.sql.SQLException;
25 |
26 | /**
27 | * @author wesleywang
28 | * @Description:
29 | * @date 2020/10/23
30 | */
31 | @Slf4j
32 | @AllArgsConstructor
33 | public class TxRawDataRepository implements RollbackInterface {
34 |
35 |
36 | private DaoTemplate txRawDataDao;
37 |
38 | private String tableName;
39 |
40 | /*
41 | * @see com.webank.blockchain.data.export.sys.db.repository.RollbackInterface#rollback(long)
42 | */
43 | public void rollback(long blockHeight){
44 | try {
45 | txRawDataDao.del(Entity.create(tableName).set("block_height",">= " + blockHeight));
46 | } catch (SQLException e) {
47 | log.error(" TxRawDataRepository rollback failed ", e);
48 | }
49 | }
50 |
51 | /*
52 | * @see com.webank.blockchain.data.export.sys.db.repository.RollbackInterface#rollback(long)
53 | */
54 | public void rollback(long startBlockHeight, long endBlockHeight){
55 | try {
56 | Db.use(ExportConstant.getCurrentContext().getDataSource()).execute(
57 | "delete from " + tableName + " where block_height >= ? and block_height< ?",startBlockHeight,endBlockHeight);
58 | } catch (SQLException e) {
59 | log.error(" TxRawDataRepository rollback failed ", e);
60 | }
61 | }
62 |
63 | public void save(TxRawData txRawData) {
64 | try {
65 | Entity entity = Entity.parse(txRawData,true,true);
66 | entity.setTableName(tableName);
67 | txRawDataDao.addForGeneratedKey(entity);
68 | } catch (SQLException e) {
69 | log.error(" TxRawDataRepository save failed ", e);
70 | }
71 |
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/repository/TxReceiptRawDataRepository.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.repository;
15 |
16 | import cn.hutool.db.DaoTemplate;
17 | import cn.hutool.db.Db;
18 | import cn.hutool.db.Entity;
19 | import com.webank.blockchain.data.export.common.entity.ExportConstant;
20 | import com.webank.blockchain.data.export.db.entity.TxReceiptRawData;
21 | import lombok.AllArgsConstructor;
22 | import lombok.extern.slf4j.Slf4j;
23 |
24 | import java.sql.SQLException;
25 |
26 | /**
27 | * @author wesleywang
28 | * @Description:
29 | * @date 2020/10/23
30 | */
31 | @Slf4j
32 | @AllArgsConstructor
33 | public class TxReceiptRawDataRepository implements RollbackInterface {
34 |
35 | private DaoTemplate txReceiptRawDataDao;
36 |
37 | private String tableName;
38 |
39 |
40 | /*
41 | * @see com.webank.blockchain.data.export.sys.db.repository.RollbackInterface#rollback(long)
42 | */
43 | @Override
44 | public void rollback(long blockHeight){
45 | try {
46 | txReceiptRawDataDao.del(Entity.create(tableName).set("block_height",">= " + blockHeight));
47 | } catch (SQLException e) {
48 | log.error(" TxRawDataRepository rollback failed ", e);
49 | }
50 | }
51 |
52 | /*
53 | * @see com.webank.blockchain.data.export.sys.db.repository.RollbackInterface#rollback(long)
54 | */
55 | @Override
56 | public void rollback(long startBlockHeight, long endBlockHeight){
57 | try {
58 | Db.use(ExportConstant.getCurrentContext().getDataSource()).execute(
59 | "delete from "+ tableName + " where block_height >= ? and block_height< ?",startBlockHeight,endBlockHeight);
60 | } catch (SQLException e) {
61 | log.error(" TxRawDataRepository rollback failed ", e);
62 | }
63 | }
64 |
65 | public void save(TxReceiptRawData txReceiptRawData) {
66 | try {
67 | Entity entity = Entity.parse(txReceiptRawData,true,true);
68 | entity.setTableName(tableName);
69 | txReceiptRawDataDao.addForGeneratedKey(entity);
70 | } catch (SQLException e) {
71 | log.error(" TxRawDataRepository save failed ", e);
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/service/DataStoreService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.service;
15 |
16 | import com.webank.blockchain.data.export.common.bo.data.BlockInfoBO;
17 | import com.webank.blockchain.data.export.common.bo.data.ContractInfoBO;
18 |
19 | /**
20 | * @author wesleywang
21 | * @Description:
22 | * @date 2020/10/26
23 | */
24 |
25 | public interface DataStoreService {
26 |
27 | void storeBlockInfoBO(BlockInfoBO blockInfo);
28 |
29 | void storeContractInfo(ContractInfoBO contractInfoBO);
30 | }
31 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/service/ESStoreService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.service;
15 |
16 | import com.webank.blockchain.data.export.common.bo.data.BlockInfoBO;
17 | import com.webank.blockchain.data.export.common.bo.data.ContractInfoBO;
18 | import com.webank.blockchain.data.export.db.dao.ESHandleDao;
19 | import lombok.Data;
20 | import lombok.extern.slf4j.Slf4j;
21 |
22 | /**
23 | * @author wesleywang
24 | * @Description:
25 | * @date 2020/10/26
26 | */
27 | @Slf4j
28 | @Data
29 | public class ESStoreService implements DataStoreService {
30 |
31 | @Override
32 | public void storeBlockInfoBO(BlockInfoBO blockInfo) {
33 | try {
34 | ESHandleDao.saveBlockInfo(blockInfo);
35 | } catch (Exception e) {
36 | log.error("ES storeBlockInfoBO failed, reason : " , e);
37 | }
38 | }
39 |
40 | @Override
41 | public void storeContractInfo(ContractInfoBO contractInfoBO) {
42 | try {
43 | ESHandleDao.saveContractInfo(contractInfoBO);
44 | } catch (Exception e) {
45 | log.error("ES storeContractInfo failed, reason : " , e);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-sdk/WeBankBlockchain-Data-Export-db/src/main/java/com/webank/blockchain/data/export/db/service/MysqlStoreService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.db.service;
15 |
16 | import com.webank.blockchain.data.export.common.bo.data.BlockInfoBO;
17 | import com.webank.blockchain.data.export.common.bo.data.ContractInfoBO;
18 | import com.webank.blockchain.data.export.db.dao.ContractInfoDAO;
19 | import com.webank.blockchain.data.export.db.dao.SaveInterface;
20 | import lombok.Data;
21 |
22 | import java.util.List;
23 |
24 | /**
25 | * @author wesleywang
26 | * @Description:
27 | * @date 2020/10/26
28 | */
29 | @Data
30 | public class MysqlStoreService implements DataStoreService {
31 |
32 | private List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.parser.enums;
15 |
16 | import lombok.AllArgsConstructor;
17 | import lombok.Getter;
18 | import lombok.extern.slf4j.Slf4j;
19 | import org.apache.commons.lang3.StringUtils;
20 |
21 | /**
22 | * JavaTypeEnum
23 | *
24 | * @Description: JavaTypeEnum
25 | * @author maojiayu
26 | * @data Apr 18, 2019 11:29:46 AM
27 | *
28 | */
29 | @AllArgsConstructor
30 | @Getter
31 | @Slf4j
32 | public enum JavaTypeEnum {
33 |
34 | BIGINTEGER("BigInteger", "Long", "bigint", "BigIntegerUtils.toLong"),
35 | Long("long", "Long", "bigint", "BigIntegerUtils.toLong"),
36 | BOOL("Boolean", "String", "varchar(8)", "String.valueOf"),
37 | STRING("String", "String", "varchar(4096)", "String.valueOf"),
38 | ByteArray("byte[]", "String", "text", "String.valueOf" ),
39 | LISTByteArray("List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.parser.tools;
15 |
16 | import com.fasterxml.jackson.databind.ObjectMapper;
17 | import lombok.extern.slf4j.Slf4j;
18 | import org.fisco.bcos.sdk.abi.wrapper.ABIDefinition;
19 | import org.fisco.bcos.sdk.abi.wrapper.ABIDefinitionFactory;
20 | import org.fisco.bcos.sdk.abi.wrapper.ContractABIDefinition;
21 | import org.fisco.bcos.sdk.crypto.CryptoSuite;
22 | import org.fisco.bcos.sdk.utils.ObjectMapperFactory;
23 |
24 | import java.io.IOException;
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | /**
29 | * ABIUtils
30 | *
31 | * @Description: ABIUtils
32 | * @author maojiayu
33 | * @data Nov 19, 2020 5:53:37 PM
34 | *
35 | */
36 | @Slf4j
37 | public class ABIUtils {
38 |
39 | public static Map Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.grafana;
15 |
16 | import java.util.Map;
17 |
18 | /**
19 | * AtomicParas
20 | *
21 | * @Description: AtomicParas
22 | * @author maojiayu
23 | * @data Mar 27, 2019 5:07:07 PM
24 | *
25 | */
26 | public interface AtomicParas Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.grafana;
15 |
16 | import com.google.common.collect.Maps;
17 | import com.webank.blockchain.data.export.config.ServiceConfig;
18 | import org.springframework.beans.factory.annotation.Autowired;
19 | import org.springframework.stereotype.Component;
20 |
21 | import java.io.File;
22 | import java.util.List;
23 | import java.util.Map;
24 |
25 | import static com.webank.blockchain.data.export.grafana.GrafanaConstant.GENERATED_GRAFANA_DEFAULT_DASHBOARD_PATH;
26 | import static com.webank.blockchain.data.export.grafana.GrafanaConstant.GRAFANA_DASHBOARD_PATH;
27 |
28 | /**
29 | * GrafanaDashboardParas
30 | *
31 | * @Description: GrafanaDashboardParas
32 | * @author maojiayu
33 | * @data Mar 28, 2019 11:12:50 AM
34 | *
35 | */
36 | @Component
37 | public class GrafanaDashboardParas implements GrafanaParas Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.grafana;
15 |
16 | import cn.hutool.core.util.StrUtil;
17 | import com.google.common.collect.Maps;
18 | import com.webank.blockchain.data.export.common.bo.contract.EventMetaInfo;
19 | import com.webank.blockchain.data.export.common.bo.contract.FieldVO;
20 | import com.webank.blockchain.data.export.config.ServiceConfig;
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.stereotype.Component;
23 | import org.springframework.util.StringUtils;
24 |
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | import static com.webank.blockchain.data.export.grafana.GrafanaConstant.GRAFANA_PANEL_TABLE_PATH;
29 |
30 | /**
31 | * GrafanaPanelParas
32 | *
33 | * @Description: GrafanaPanelParas
34 | * @author maojiayu
35 | * @data Mar 27, 2019 4:48:14 PM
36 | *
37 | */
38 | @Component
39 | public class GrafanaPanelTableParasEvent implements AtomicParas Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.grafana;
15 |
16 | import cn.hutool.core.util.StrUtil;
17 | import com.google.common.collect.Maps;
18 | import com.webank.blockchain.data.export.common.bo.contract.FieldVO;
19 | import com.webank.blockchain.data.export.common.bo.contract.MethodMetaInfo;
20 | import com.webank.blockchain.data.export.config.ServiceConfig;
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.stereotype.Component;
23 | import org.springframework.util.StringUtils;
24 |
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | import static com.webank.blockchain.data.export.grafana.GrafanaConstant.GRAFANA_PANEL_TABLE_PATH;
29 |
30 | /**
31 | * GrafanaPanelParas
32 | *
33 | * @Description: GrafanaPanelParas
34 | * @author maojiayu
35 | * @data Mar 27, 2019 4:48:14 PM
36 | *
37 | */
38 | @Component
39 | public class GrafanaPanelTableParasMethod implements AtomicParas Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.export.grafana;
15 |
16 | import java.util.List;
17 |
18 | /**
19 | * GrafanaParas
20 | *
21 | * @Description: GrafanaParas
22 | * @author maojiayu
23 | * @param > {
38 |
39 | @Autowired
40 | private ServiceConfig config;
41 |
42 | @Override
43 | public Map
> {
28 |
29 | public String getGeneratedFilePath();
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-service/src/main/resources/templates/grafana/panel_table.txt:
--------------------------------------------------------------------------------
1 | {
2 | "columns": [],
3 | "datasource": "MySQL",
4 | "fontSize": "110%",
5 | "gridPos": {
6 | "h": 8,
7 | "w": 24,
8 | "x": ${gridXPos},
9 | "y": ${gridYPos}
10 | },
11 | "id": ${id},
12 | "links": [],
13 | "pageSize": 10,
14 | "scroll": true,
15 | "showHeader": true,
16 | "sort": {
17 | "col": 0,
18 | "desc": true
19 | },
20 | "styles": [
21 | {
22 | "alias": "depot_updatetime",
23 | "dateFormat": "YYYY-MM-DD HH:mm:ss",
24 | "pattern": "depot_updatetime",
25 | "type": "number"
26 | },
27 | {
28 | "alias": "",
29 | "colorMode": "value",
30 | "colors": [
31 | "#73BF69",
32 | "rgba(237, 129, 40, 0.89)",
33 | "rgba(245, 54, 54, 0.9)"
34 | ],
35 | "decimals": 0,
36 | "pattern": "block_height",
37 | "thresholds": [],
38 | "type": "string",
39 | "unit": "short"
40 | },
41 | {
42 | "alias": "",
43 | "colorMode": "value",
44 | "colors": [
45 | "#73BF69",
46 | "rgba(237, 129, 40, 0.89)",
47 | "rgba(245, 54, 54, 0.9)"
48 | ],
49 | "decimals": 0,
50 | "pattern": "pk_id",
51 | "thresholds": [],
52 | "type": "string",
53 | "unit": "short"
54 | }
55 | ],
56 | "targets": [
57 | {
58 | "format": "table",
59 | "group": [],
60 | "metricColumn": "none",
61 | "rawQuery": true,
62 | "rawSql": "select * from ${table_name} order by depot_updatetime;",
63 | "refId": "A",
64 | "select": [
65 | [
66 | {
67 | "params": [
68 | "value"
69 | ],
70 | "type": "column"
71 | }
72 | ]
73 | ],
74 | "timeColumn": "time",
75 | "where": [
76 | {
77 | "name": "$__timeFilter",
78 | "params": [],
79 | "type": "macro"
80 | }
81 | ]
82 | }
83 | ],
84 | "timeFrom": null,
85 | "timeShift": null,
86 | "title": "${title}",
87 | "transform": "table",
88 | "type": "table"
89 | }
--------------------------------------------------------------------------------
/WeBankBlockchain-Data-Export-service/src/test/java/com/webank/blockchain/data/export/grafana/GrafanaDashboardParasTest.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.export.grafana;
2 |
3 |
4 | import com.google.common.collect.ImmutableList;
5 | import com.google.common.collect.ImmutableMap;
6 | import com.google.common.collect.Maps;
7 | import com.webank.blockchain.data.export.config.ServiceConfig;
8 | import org.junit.Before;
9 | import org.junit.Test;
10 | import org.mockito.Mock;
11 | import org.mockito.MockitoAnnotations;
12 | import org.springframework.test.util.ReflectionTestUtils;
13 |
14 | import java.util.List;
15 | import java.util.Map;
16 |
17 | import static org.junit.Assert.assertTrue;
18 | import static org.mockito.Mockito.when;
19 |
20 |
21 | public class GrafanaDashboardParasTest {
22 | private static String PREFIX = "prefix";
23 | private static String SUFFIX = "suffix";
24 | private static List