Skip to content

Commit

Permalink
Introduce Anchor peer API and other refractoring (#120)
Browse files Browse the repository at this point in the history
* Introduce Anchor peer API and other refractoring

Signed-off-by: n0s09by <Nidhi.singh0@walmart.com>

* Enhancement: Merged two services into one for building writeSet and few other refractor

Signed-off-by: n0s09by <Nidhi.singh0@walmart.com>

* Enhancement:removed private variable from service

Signed-off-by: n0s09by <Nidhi.singh0@walmart.com>

---------

Signed-off-by: n0s09by <Nidhi.singh0@walmart.com>
  • Loading branch information
nidhi-singh02 authored Jan 11, 2024
1 parent 75664d6 commit 7729b7d
Show file tree
Hide file tree
Showing 12 changed files with 621 additions and 421 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package hlf.java.rest.client.controller;

import hlf.java.rest.client.model.ChannelUpdateParamsDTO;
import hlf.java.rest.client.model.ClientResponseModel;
import hlf.java.rest.client.model.CommitChannelParamsDTO;
import hlf.java.rest.client.model.NewOrgParamsDTO;
import hlf.java.rest.client.service.NetworkStatus;
import hlf.java.rest.client.util.SerializationUtil;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -53,7 +53,7 @@ public ResponseEntity<ClientResponseModel> getChannelConfiguration(
@PutMapping(value = "/channel/{channelName}/configuration/config_update")
public ResponseEntity<ClientResponseModel> generateConfigUpdateFile(
@PathVariable @Validated String channelName,
@RequestBody @Validated NewOrgParamsDTO organizationDetails) {
@RequestBody @Validated ChannelUpdateParamsDTO organizationDetails) {
return networkStatus.generateConfigUpdate(channelName, organizationDetails);
}

Expand Down Expand Up @@ -102,10 +102,9 @@ public ResponseEntity<ClientResponseModel> commitSignedChannelConfig(
@PostMapping(value = "/channel/{channelName}/new_org")
public ResponseEntity<ClientResponseModel> addOrgToChannel(
@PathVariable @Validated String channelName,
@RequestBody @Validated NewOrgParamsDTO organizationDetails) {
@RequestBody @Validated ChannelUpdateParamsDTO organizationDetails) {
return networkStatus.addOrgToChannel(channelName, organizationDetails);
}

/**
* Use to decode an base64 encoded json file, with options to also decode the interior elements
* and/or print the output in a cleaner format
Expand All @@ -126,4 +125,21 @@ public ResponseEntity<ClientResponseModel> getDeserializedJson(
@RequestParam(name = "prettyPrint", required = true) boolean prettyPrint) {
return serializationUtil.decodeContents(encodedJson, decodeInterior, prettyPrint);
}

/**
* Add anchor peer(s) of an organization to a channel. Anchor peer addition should be done once
* the peer nodes of the organization have joined the channel.
*
* @param channelName - the name of the channel for which you wish to add the anchor peer nodes
* to.
* @param channelUpdateParamsDTO - contains the details for the organization peers you wish to be
* added to the channel as anchor peer.
* @return ResponseEntity<ClientResponseModel> - contains the result of the operation.
*/
@PostMapping(value = "/channel/{channelName}/add_anchor_peer")
public ResponseEntity<ClientResponseModel> addAnchorPeersToChannel(
@PathVariable @Validated String channelName,
@RequestBody @Validated ChannelUpdateParamsDTO channelUpdateParamsDTO) {
return networkStatus.addAnchorPeersToChannel(channelName, channelUpdateParamsDTO);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import lombok.Data;

@Data
public class NewOrgParamsDTO {

private String organizationName;
public class ChannelUpdateParamsDTO {
private String organizationMspId;
private MSPDTO mspDTO;
private List<AnchorPeerDTO> anchorPeerDTOs;
private MSPDTO mspDTO;
}
9 changes: 6 additions & 3 deletions src/main/java/hlf/java/rest/client/service/NetworkStatus.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package hlf.java.rest.client.service;

import hlf.java.rest.client.model.ChannelUpdateParamsDTO;
import hlf.java.rest.client.model.ClientResponseModel;
import hlf.java.rest.client.model.CommitChannelParamsDTO;
import hlf.java.rest.client.model.NewOrgParamsDTO;
import org.springframework.http.ResponseEntity;

public interface NetworkStatus {
Expand All @@ -13,11 +13,14 @@ ResponseEntity<ClientResponseModel> signChannelConfigTransaction(
String channelName, String configUpdate);

ResponseEntity<ClientResponseModel> generateConfigUpdate(
String channelName, NewOrgParamsDTO organizationDetails);
String channelName, ChannelUpdateParamsDTO organizationDetails);

ResponseEntity<ClientResponseModel> commitChannelConfigTransaction(
String channelName, CommitChannelParamsDTO commitChannelParamsDTO);

ResponseEntity<ClientResponseModel> addOrgToChannel(
String channelName, NewOrgParamsDTO organizationDetails);
String channelName, ChannelUpdateParamsDTO organizationDetails);

ResponseEntity<ClientResponseModel> addAnchorPeersToChannel(
String channelName, ChannelUpdateParamsDTO channelUpdateParamsDTO);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package hlf.java.rest.client.service;

import hlf.java.rest.client.exception.ServiceException;
import hlf.java.rest.client.model.NewOrgParamsDTO;
import hlf.java.rest.client.model.ChannelUpdateParamsDTO;
import org.hyperledger.fabric.protos.common.Configtx.ConfigGroup;

public interface AddOrgToChannelWriteSetBuilder {
public interface UpdateChannel {

ConfigGroup buildWriteset(ConfigGroup readset, NewOrgParamsDTO organizationDetails)
ConfigGroup buildWriteset(ConfigGroup readset, ChannelUpdateParamsDTO organizationDetails)
throws ServiceException;
}
Loading

0 comments on commit 7729b7d

Please sign in to comment.