org.hyperledger.fabric.client.NetworkImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fabric-gateway Show documentation
Show all versions of fabric-gateway Show documentation
Hyperledger Fabric Gateway client API for Java
The newest version!
/*
* Copyright 2019 IBM All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.client;
import com.google.protobuf.ByteString;
import io.grpc.CallOptions;
import java.util.Objects;
import java.util.function.UnaryOperator;
import org.hyperledger.fabric.protos.common.Block;
import org.hyperledger.fabric.protos.peer.BlockAndPrivateData;
import org.hyperledger.fabric.protos.peer.FilteredBlock;
final class NetworkImpl implements Network {
private final GatewayClient client;
private final SigningIdentity signingIdentity;
private final String channelName;
private final ByteString tlsCertificateHash;
NetworkImpl(
final GatewayClient client,
final SigningIdentity signingIdentity,
final String channelName,
final ByteString tlsCertificateHash) {
Objects.requireNonNull(channelName, "network name");
this.client = client;
this.signingIdentity = signingIdentity;
this.channelName = channelName;
this.tlsCertificateHash = tlsCertificateHash;
}
@Override
public Contract getContract(final String chaincodeName, final String contractName) {
return new ContractImpl(client, signingIdentity, channelName, chaincodeName, contractName);
}
@Override
public Contract getContract(final String chaincodeName) {
return new ContractImpl(client, signingIdentity, channelName, chaincodeName);
}
@Override
public String getName() {
return channelName;
}
@Override
public CloseableIterator getChaincodeEvents(
final String chaincodeName, final UnaryOperator options) {
return newChaincodeEventsRequest(chaincodeName).build().getEvents(options);
}
@Override
public ChaincodeEventsRequest.Builder newChaincodeEventsRequest(final String chaincodeName) {
return new ChaincodeEventsBuilder(client, signingIdentity, channelName, chaincodeName);
}
@Override
public CloseableIterator getBlockEvents(final UnaryOperator options) {
return newBlockEventsRequest().build().getEvents(options);
}
@Override
public BlockEventsRequest.Builder newBlockEventsRequest() {
return new BlockEventsBuilder(client, signingIdentity, channelName, tlsCertificateHash);
}
@Override
public CloseableIterator getFilteredBlockEvents(final UnaryOperator options) {
return newFilteredBlockEventsRequest().build().getEvents(options);
}
@Override
public FilteredBlockEventsRequest.Builder newFilteredBlockEventsRequest() {
return new FilteredBlockEventsBuilder(client, signingIdentity, channelName, tlsCertificateHash);
}
@Override
public CloseableIterator getBlockAndPrivateDataEvents(
final UnaryOperator options) {
return newBlockAndPrivateDataEventsRequest().build().getEvents(options);
}
@Override
public BlockAndPrivateDataEventsRequest.Builder newBlockAndPrivateDataEventsRequest() {
return new BlockAndPrivateDataEventsBuilder(client, signingIdentity, channelName, tlsCertificateHash);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy