-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature to listen and report PDC events (#3)
* Allow block listener to specify the peer listen options 1. Enable private data capability as part of peer listen request on channel service. 2. Refactoring Signed-off-by: S m, Aruna <[email protected]> * Private Data Collections in published event structure The commit also refactors the configuration files and allows for bean creation instead of explicit singleton class definitions. Signed-off-by: weihong-ou <[email protected]> Signed-off-by: S m, Aruna <[email protected]> * Refactor and fix test cases 1. Move configuration to the Config package. 2. Refactor within components and services to move them to appropriate packages. Signed-off-by: S m, Aruna <[email protected]> * Update the fabric-sdk-java version Introduce a version with private data events in the SDK. Signed-off-by: S m, Aruna <[email protected]> Co-authored-by: weihong-ou <[email protected]>
- Loading branch information
1 parent
7d32d41
commit 845b096
Showing
33 changed files
with
532 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,4 +77,6 @@ target/ | |
.env | ||
/config/application.yml | ||
/config/connection-* | ||
docker-compose-* | ||
docker-compose-* | ||
secrets | ||
stores |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ services: | |
networks: | ||
default: | ||
external: | ||
name: net_test | ||
name: net_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
src/main/java/hlf/java/rest/client/config/ApplicationConstants.java
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
src/main/java/hlf/java/rest/client/config/ApplicationProperties.java
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
src/main/java/hlf/java/rest/client/config/FabricProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package hlf.java.rest.client.config; | ||
|
||
import javax.annotation.PostConstruct; | ||
import lombok.Data; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* FabricProperties reads and binds with the application.yml and provide all the configuration as a | ||
* bean configuration To use any configuration, just autowire and call the associated "get" method | ||
*/ | ||
@Data | ||
@Configuration | ||
@ConfigurationProperties(prefix = "fabric") | ||
public class FabricProperties { | ||
|
||
private static final String SYSTEM_PROP_FABRIC_SERVICE_DISCOVERY_LOCALHOST = | ||
"org.hyperledger.fabric.sdk.service_discovery.as_localhost"; | ||
|
||
private boolean localhostReportAddress; | ||
private WalletConfig wallet; | ||
private OrgConnectionConfig orgConnectionConfig; | ||
private Client client; | ||
private Events events; | ||
|
||
@Data | ||
public static class WalletConfig { | ||
private String path; | ||
private AdminUser adminUser; | ||
private ClientUser clientUser; | ||
|
||
@Data | ||
public static class AdminUser { | ||
private String name; | ||
} | ||
|
||
@Data | ||
public static class ClientUser { | ||
private String name; | ||
} | ||
} | ||
|
||
@Data | ||
public static class OrgConnectionConfig { | ||
private String path; | ||
private String filename; | ||
} | ||
|
||
@Data | ||
public static class Client { | ||
private Rest rest; | ||
|
||
@Data | ||
public static class Rest { | ||
private String apikey; | ||
} | ||
} | ||
|
||
@Data | ||
@ConditionalOnProperty(prefix = "fabric.events", name = "enable", havingValue = "true") | ||
public static class Events { | ||
private boolean enable; | ||
private String chaincode; | ||
private String block; | ||
} | ||
|
||
/** | ||
* Forces Hyperledger Service Discovery to report the localhost address for all nodes (peers & | ||
* ordering service) when client is running on local machine. This property allows client to node | ||
* connectivity when nodes cannot be accessed directly by the client on their public network | ||
* address as in the case above. | ||
*/ | ||
@PostConstruct | ||
private void systemVariableSetup() { | ||
System.setProperty( | ||
SYSTEM_PROP_FABRIC_SERVICE_DISCOVERY_LOCALHOST, | ||
String.valueOf(this.isLocalhostReportAddress())); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/hlf/java/rest/client/config/GatewayConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package hlf.java.rest.client.config; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.hyperledger.fabric.gateway.Gateway; | ||
import org.hyperledger.fabric.gateway.Wallet; | ||
import org.hyperledger.fabric.gateway.Wallets; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** Configure Gateway connection for the Fabric network. */ | ||
@Slf4j | ||
@Configuration | ||
public class GatewayConfig { | ||
|
||
@Autowired FabricProperties fabricProperties; | ||
|
||
/** | ||
* Create the gateway connection for connecting to the peer. | ||
* | ||
* @return gateway Gateway object to connect to Fabric network | ||
* @throws IOException | ||
*/ | ||
@Bean | ||
public Gateway gateway(Wallet wallet) throws IOException { | ||
// Load the Network Connection Configuration path | ||
Path networkConfigPath = | ||
Paths.get( | ||
fabricProperties.getOrgConnectionConfig().getPath(), | ||
fabricProperties.getOrgConnectionConfig().getFilename()); | ||
// Create the gateway builder based on the path to the org configuration file | ||
// using the specified user, then connect | ||
Gateway.Builder builder = Gateway.createBuilder(); | ||
builder | ||
.identity(wallet, fabricProperties.getWallet().getClientUser().getName()) | ||
.networkConfig(networkConfigPath) | ||
.discovery(true); | ||
return builder.connect(); | ||
} | ||
|
||
/** | ||
* Obtain the Wallet details containing the user id information. | ||
* | ||
* @return wallet Wallet pull credentials from wallet | ||
* @throws IOException | ||
*/ | ||
@Bean | ||
public Wallet wallet() throws IOException { | ||
log.info("Obtain the Wallet containing Admin and Client user information"); | ||
// Load a file system based wallet for managing identities. | ||
Path walletPath = Paths.get(fabricProperties.getWallet().getPath()); | ||
return Wallets.newFileSystemWallet(walletPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.