• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

hyperledger/fabric-sdk-java

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

hyperledger/fabric-sdk-java

开源软件地址:

https://github.com/hyperledger/fabric-sdk-java

开源编程语言:

Java 97.5%

开源软件介绍:

Hyperledger Fabric SDK for Java

BranchBuild status
main
release-2.2
release-1.4

Build Status This project provides a low-level API for interacting with Hyperledger Fabric blockchain networks, and is used by the high-level Hyperledger Fabric Gateway SDK for Java:

For building Hyperledger Fabric blockchain client applications, you are strongly encouraged to use the high level API.

The information below is intended for contributors to this repository.


Introduction for contributors

The SDK provides a layer of abstraction on top of the wire-level protobuf based communication protocol used by client applications to interact with a Hyperledger Fabric blockchain network. It allows Java applications to manage the lifecycle of Hyperledger channels and user chaincode. The SDK also provides a means to execute user chaincode, query blocks and transactions on the channel, and monitor events on the channel.

The SDK acts on behalf of a particular User which is defined by the embedding application through the implementation of the SDK's User interface.

Note, the SDK does not provide a means of persistence for the application defined channels and user artifacts on the client. This is left for the embedding application to best manage. Channels may be serialized via Java serialization in the context of a client. Channels deserialized are not in an initialized state. Applications need to handle migration of serialized files between versions.

The SDK also provides a client for Hyperledger's certificate authority. The SDK is however not dependent on this particular implementation of a certificate authority. Other Certificate authority's maybe used by implementing the SDK's Enrollment interface.

This provides a summary of steps required to get you started with building and using the Java SDK. Please note that this is not the API documentation or a tutorial for the SDK, this will only help you familiarize to get started with the SDK if you are new in this domain.

Release notes

Release Notes Summary
2.1 v2.1 release notes Minor update
2.0 v2.0 release notes
  • New lifecycle chaincode management
  • Connection config handlers
  • Application setting executor service
  • Queued block listener
1.4 None Minor updates no Fabric changes
1.3 v1.3 release notes
  • Java chaincode support
  • Query chaincode collection configuration
  • Identity Mixer transaction unlinkabilty support
1.2 v1.2 release notes
  • Private data collection support
  • Service discovery
  • Fabric CA certificate API
1.1 v1.1 release notes
  • Channel service events
  • FilterBlocks
  • JCA/JCE compliance
  • Chaincode events
  • Node chaincode

Checkout SDK from Github

git clone https://github.com/hyperledger/fabric-sdk-java.git
cd fabric-sdk-java/

Production Java applications

For Java applications use the latest released version of the SDK v1.4.x releases:

     <!-- https://mvnrepository.com/artifact/org.hyperledger.fabric-sdk-java/fabric-sdk-java -->
     <dependency>
         <groupId>org.hyperledger.fabric-sdk-java</groupId>
         <artifactId>fabric-sdk-java</artifactId>
         <version>1.4.7</version>
     </dependency>

For v2.0 work in progress use 2.0.0-SNAPSHOT builds

Work in progress 2.0.0 SNAPSHOT builds can be used by adding the following to your application's pom.xml

    <repositories>
        <repository>
            <id>snapshots-repo</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

<dependencies>

        <!-- https://mvnrepository.com/artifact/org.hyperledger.fabric-sdk-java/fabric-sdk-java -->
        <dependency>
            <groupId>org.hyperledger.fabric-sdk-java</groupId>
            <artifactId>fabric-sdk-java</artifactId>
            <version>2.0.0-SNAPSHOT</version>
        </dependency>

</dependencies>

Java and Node Chaincode environment

You may also need to on your v2.1 Fabric network docker deployment explicitly pull the Java and Node chaincode environments for now.

docker pull hyperledger-fabric.jfrog.io/fabric-nodeenv:amd64-2.1.0-stable&&docker tag hyperledger-fabric.jfrog.io/fabric-nodeenv:amd64-2.1.0-stable hyperledger/fabric-nodeenv:amd64-latest&&docker tag hyperledger-fabric.jfrog.io/fabric-nodeenv:amd64-2.1.0-stable hyperledger/fabric-nodeenv

docker pull hyperledger-fabric.jfrog.io/fabric-javaenv:amd64-2.1.0-stable&&docker tag hyperledger-fabric.jfrog.io/fabric-javaenv:amd64-2.1.0-stable hyperledger/fabric-javaenv:amd64-latest&&docker tag hyperledger-fabric.jfrog.io/fabric-javaenv:amd64-2.1.0-stable hyperledger/fabric-javaenv

Known limitations and restrictions


SDK dependencies

SDK depends on few third party libraries that must be included in your classpath when using the JAR file. To get a list of dependencies, refer to pom.xml file or run mvn dependency:tree or mvn dependency:list. Alternatively, mvn dependency:analyze-report will produce a report in HTML format in target directory listing all the dependencies in a more readable format.

To build this project, the following dependencies must be met

  • JDK 1.8 or above
  • Apache Maven 3.5.0

To run the integration tests Fabric and Fabric CA is needed which require

  • Docker 18.03
  • Docker compose 1.21.2

Using the SDK

Setting Up Eclipse

If you want to get started using the Fabric Java SDK with Eclipse, refer to the instructions at: ./docs/EclipseSetup.md

Compiling

Once your JAVA_HOME points to your installation of JDK 1.8 (or above) and JAVA_HOME/bin and Apache maven are in your PATH, issue the following command to build the jar file: mvn install or mvn install -DskipTests if you don't want to run the unit tests

Running the unit tests

To run the unit tests, please use mvn install which will run the unit tests and build the jar file.

Many unit tests will test failure condition's resulting in exceptions and stack traces being displayed. This is not an indication of failure!

[INFO] BUILD SUCCESS At the end is usually a very reliable indication that all tests have passed successfully!

Running the integration tests

The script below both sets up the test environment and runs the tests.

./scripts/run-integration-tests.sh

End to end test scenario

Following the below integration tests/example code shows almost all that the SDK can do. To learn the SDK you must have some understanding first of Fabric Hyperledger. Then it's best to study the integrations tests and better yet work with them in a debugger to follow the code ( a live demo ). Start first with End2endIT.java and then End2endAndBackAgainIT.java samples before exploring the other samples. Then once you understand them you can cut and paste from there to your own application. ( the code is done for you! )

Note These samples are for testing, validating your environment and showing how to use the APIs. Most show a simple balance transfer. They are not meant to represent best practices in design or use of chaincode or the use of the SDK.

Integration Test Summary and notes
End2endLifecycleIT.java
  • New lifecycle chaincode management APIs (v2.0)

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap