Use new default call options API in Java off_chain_data sample

Also use hyperlinks for easier navigation to code mentioned in the README.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
This commit is contained in:
Mark S. Lewis 2022-06-09 17:31:03 +01:00 committed by Dave Enyeart
parent 8ca50df4ff
commit adfd850e64
3 changed files with 12 additions and 14 deletions

View file

@ -17,14 +17,14 @@ This sample uses the block event listening capability of the [Fabric Gateway cli
The client application provides several "commands" that can be invoked using the command-line: The client application provides several "commands" that can be invoked using the command-line:
- **getAllAssets**: Retrieve the current details of all assets recorded on the ledger. See: - **getAllAssets**: Retrieve the current details of all assets recorded on the ledger. See:
- TypeScript: `application-typescript/src/getAllAssets.ts` - TypeScript: [application-typescript/src/getAllAssets.ts](application-typescript/src/getAllAssets.ts)
- Java: `application-java/app/src/main/java/GetAllAssets.java` - Java: [application-java/app/src/main/java/GetAllAssets.java](application-java/app/src/main/java/GetAllAssets.java)
- **listen**: Listen for block events, and use them to replicate ledger updates in an off-chain data store. See: - **listen**: Listen for block events, and use them to replicate ledger updates in an off-chain data store. See:
- TypeScript: `application-typescript/src/listen.ts` - TypeScript: [application-typescript/src/listen.ts](application-typescript/src/listen.ts)
- Java: `application-java/app/src/main/java/Transact.java` - Java: [application-java/app/src/main/java/Transact.java](application-java/app/src/main/java/Transact.java)
- **transact**: Submit a set of transactions to create, modify and delete assets. See: - **transact**: Submit a set of transactions to create, modify and delete assets. See:
- TypeScript: `application-typescript/src/transact.ts` - TypeScript: [application-typescript/src/transact.ts](application-typescript/src/transact.ts)
- Java: `application-java/app/src/main/java/Transact.java` - Java: [application-java/app/src/main/java/Transact.java](application-java/app/src/main/java/Transact.java)
To keep the sample code concise, the **listen** command writes ledger updates to an output file named `store.log` in the current working directory (which for the Java sample is the `application-java/app` directory). A real implementation could write ledger updates directly to an off-chain data store of choice. You can inspect the information captured in this file as you run the sample. To keep the sample code concise, the **listen** command writes ledger updates to an output file named `store.log` in the current working directory (which for the Java sample is the `application-java/app` directory). A real implementation could write ledger updates directly to an off-chain data store of choice. You can inspect the information captured in this file as you run the sample.

View file

@ -17,9 +17,8 @@ repositories {
} }
dependencies { dependencies {
// implementation 'com.google.guava:guava:30.1.1-jre'
implementation 'io.grpc:grpc-netty-shaded:1.46.0' implementation 'io.grpc:grpc-netty-shaded:1.46.0'
implementation 'org.hyperledger.fabric:fabric-gateway:1.0.2-dev-20220518-1' implementation 'org.hyperledger.fabric:fabric-gateway:1.0.2-dev-20220608-5'
implementation 'com.google.code.gson:gson:2.9.0' implementation 'com.google.code.gson:gson:2.9.0'
} }
@ -30,7 +29,7 @@ java {
} }
checkstyle { checkstyle {
toolVersion '10.2' toolVersion '10.3'
} }
application { application {

View file

@ -20,7 +20,6 @@ import io.grpc.Channel;
import io.grpc.ManagedChannel; import io.grpc.ManagedChannel;
import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts; import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder; import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
import org.hyperledger.fabric.client.CallOption;
import org.hyperledger.fabric.client.Gateway; import org.hyperledger.fabric.client.Gateway;
import org.hyperledger.fabric.client.identity.Identities; import org.hyperledger.fabric.client.identity.Identities;
import org.hyperledger.fabric.client.identity.Identity; import org.hyperledger.fabric.client.identity.Identity;
@ -92,10 +91,10 @@ public final class Connections {
.identity(newIdentity()) .identity(newIdentity())
.signer(newSigner()) .signer(newSigner())
.connection(grpcChannel) .connection(grpcChannel)
.evaluateOptions(CallOption.deadlineAfter(EVALUATE_TIMEOUT_SECONDS, TimeUnit.SECONDS)) .evaluateOptions(options -> options.withDeadlineAfter(EVALUATE_TIMEOUT_SECONDS, TimeUnit.SECONDS))
.endorseOptions(CallOption.deadlineAfter(ENDORSE_TIMEOUT_SECONDS, TimeUnit.SECONDS)) .endorseOptions(options -> options.withDeadlineAfter(ENDORSE_TIMEOUT_SECONDS, TimeUnit.SECONDS))
.submitOptions(CallOption.deadlineAfter(SUBMIT_TIMEOUT_SECONDS, TimeUnit.SECONDS)) .submitOptions(options -> options.withDeadlineAfter(SUBMIT_TIMEOUT_SECONDS, TimeUnit.SECONDS))
.commitStatusOptions(CallOption.deadlineAfter(COMMIT_STATUS_TIMEOUT_SECONDS, TimeUnit.SECONDS)); .commitStatusOptions(options -> options.withDeadlineAfter(COMMIT_STATUS_TIMEOUT_SECONDS, TimeUnit.SECONDS));
} }
private static Identity newIdentity() throws IOException, CertificateException { private static Identity newIdentity() throws IOException, CertificateException {