Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit e0af668

Browse files
FABJ-450 Access to Peer URL from NetworkConfig
Implementation of NetworkConfig.getPeerUrl(name) Change-Id: If5b4c112837b2439367a516a13e0138d0d0f9c99 Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
1 parent d119aad commit e0af668

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/main/java/org/hyperledger/fabric/sdk/NetworkConfig.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,30 @@ public void setOrdererProperties(String name, Properties properties) throws Inva
188188
setNodeProperties("Orderer", name, orderers, properties);
189189
}
190190

191+
private String getNodeUrl(String type, String name, Map<String, Node> nodes) throws InvalidArgumentException {
192+
if (isNullOrEmpty(name)) {
193+
throw new InvalidArgumentException("Parameter name is null or empty.");
194+
}
195+
196+
Node node = nodes.get(name);
197+
if (node == null) {
198+
throw new InvalidArgumentException(format("%s %s not found.", type, name));
199+
}
200+
201+
return node.getUrl();
202+
}
203+
204+
/**
205+
* Get URL for a specific peer.
206+
*
207+
* @param name Name of peer to get the URL for.
208+
* @return The peer's URL.
209+
* @throws InvalidArgumentException
210+
*/
211+
public String getPeerUrl(String name) throws InvalidArgumentException {
212+
return getNodeUrl("Peer", name, peers);
213+
}
214+
191215
// Organizations, keyed on org name (and not on mspid!)
192216
private Map<String, OrgInfo> organizations;
193217

@@ -1251,6 +1275,7 @@ public Enrollment getEnrollment() {
12511275
return enrollment;
12521276
}
12531277

1278+
@Override
12541279
public String getMspId() {
12551280
return mspid;
12561281
}

0 commit comments

Comments
 (0)