Skip to content

Commit

Permalink
Added getActiveOrderersList functionality
Browse files Browse the repository at this point in the history
Signed-off-by: ArchanaArige <nigam_archana@yahoo.co.in>

Modified the getPeersStatus functionality to embibe the status of the peers

Signed-off-by: ArchanaArige <nigam_archana@yahoo.co.in>

Resolved the review comments

Signed-off-by: ArchanaArige <nigam_archana@yahoo.co.in>
  • Loading branch information
ArchanaArige authored and arsulegai committed Feb 3, 2023
1 parent 287d3ae commit 0db8369
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
24 changes: 19 additions & 5 deletions app/platform/fabric/Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class Proxy {
async getPeersStatus(network_id, channel_genesis_hash) {
const client = await this.platform.getClient(network_id);
const channel_name = client.getChannelNameByHash(channel_genesis_hash);
let orderersList = await client.fabricGateway.getActiveOrderersList(channel_name);
const nodes = await this.persistence
.getMetricService()
.getPeerList(network_id, channel_genesis_hash);
Expand All @@ -123,9 +124,10 @@ export class Proxy {
const peers = [];

for (const node of nodes) {
node.status = "";
if (node.peer_type === 'PEER') {
node.status = 'DOWN';
if (discover_results && discover_results.peers_by_org) {
node.status = "DOWN";
const org = discover_results.peers_by_org[node.mspid];
if (org === undefined) {
continue;
Expand All @@ -135,23 +137,35 @@ export class Proxy {
node.ledger_height_low = peer.ledgerHeight.low;
node.ledger_height_high = peer.ledgerHeight.high;
node.ledger_height_unsigned = peer.ledgerHeight.unsigned;
node.status = 'UP';
}
}
}
// Sometime 'peers_by_org' property is not included in discover result
if(typeof node.ledger_height_low === 'undefined')
if (typeof node.ledger_height_low === 'undefined') {
node.ledger_height_low = '-';
if(typeof node.ledger_height_high === 'undefined')
}
if (typeof node.ledger_height_high === 'undefined') {
node.ledger_height_high = '-';
if(typeof node.ledger_height_unsigned === 'undefined')
}
if (typeof node.ledger_height_unsigned === 'undefined') {
node.ledger_height_unsigned = '-';
}
peers.push(node);
} else if (node.peer_type === 'ORDERER') {
node.status = 'DOWN';
node.ledger_height_low = '-';
node.ledger_height_high = '-';
node.ledger_height_unsigned = '-';
peers.push(node);
let orderersCount = orderersList.length;
if (orderersCount != 0) {
for (const orderer of orderersList) {
if (orderer.name === node.requests && orderer.connected == true) {
node.status = 'UP';
}
}
}
peers.push(node);
}
}

Expand Down
13 changes: 13 additions & 0 deletions app/platform/fabric/gateway/FabricGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,4 +488,17 @@ export class FabricGateway {

return null;
}

async getActiveOrderersList(channel_name) {
const network = await this.gateway.getNetwork(channel_name);
let orderers = [];
for (let [orderer, ordererMetadata] of network.discoveryService.channel.committers) {
let ordererAtrributes = {
name: orderer,
connected: ordererMetadata.connected
}
orderers.push(ordererAtrributes);
}
return orderers;
}
}

0 comments on commit 0db8369

Please sign in to comment.