Skip to content

Commit 8b8ddc6

Browse files
authored
BE-829 Distinguish each node with both IP and Port (#203)
Signed-off-by: Atsushi Neki <[email protected]>
1 parent ba7739a commit 8b8ddc6

File tree

4 files changed

+21
-40
lines changed

4 files changed

+21
-40
lines changed

app/platform/fabric/Proxy.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export class Proxy {
131131
continue;
132132
}
133133
for (const peer of org.peers) {
134-
if (peer.endpoint.indexOf(node.server_hostname) > -1) {
134+
if (peer.endpoint === node.requests) {
135135
node.ledger_height_low = peer.ledgerHeight.low;
136136
node.ledger_height_high = peer.ledgerHeight.high;
137137
node.ledger_height_unsigned = peer.ledgerHeight.unsigned;
@@ -141,16 +141,9 @@ export class Proxy {
141141
peers.push(node);
142142
} else if (node.peer_type === 'ORDERER') {
143143
node.status = 'DOWN';
144-
if (discover_results && discover_results.orderers) {
145-
const org = discover_results.orderers[node.mspid];
146-
for (const endpoint of org.endpoints) {
147-
if (endpoint.host.indexOf(node.server_hostname) > -1) {
148-
node.ledger_height_low = '-';
149-
node.ledger_height_high = '-';
150-
node.ledger_height_unsigned = '-';
151-
}
152-
}
153-
}
144+
node.ledger_height_low = '-';
145+
node.ledger_height_high = '-';
146+
node.ledger_height_unsigned = '-';
154147
peers.push(node);
155148
}
156149
}

app/platform/fabric/sync/SyncService.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -212,29 +212,18 @@ export class SyncServices {
212212
* @memberof SyncServices
213213
*/
214214
async insertNewPeer(peer, channel_genesis_hash, client) {
215-
let eventurl = '';
216-
let requesturl = peer.endpoint;
217215
const network_id = client.getNetworkId();
218-
const host_port = peer.endpoint.split(':');
219-
const peers = client.getNetworkConfig().peers;
220-
if (peers && peers[host_port[0]] && peers[host_port[0]].url) {
221-
requesturl = peers[host_port[0]].url;
222-
}
223-
if (peers && peers[host_port[0]] && peers[host_port[0]].eventUrl) {
224-
eventurl = peers[host_port[0]].eventUrl;
225-
}
226216

227217
const peer_row = {
228218
mspid: peer.mspid,
229-
requests: requesturl.replace(/^grpcs*:\/\//, ''),
230-
events: eventurl,
231-
server_hostname: host_port[0],
219+
requests: peer.endpoint,
220+
server_hostname: peer.endpoint,
232221
channel_genesis_hash,
233222
peer_type: 'PEER'
234223
};
235224
await this.persistence.getCrudService().savePeer(network_id, peer_row);
236225
const channel_peer_row = {
237-
peerid: host_port[0],
226+
peerid: peer.endpoint,
238227
channelid: channel_genesis_hash
239228
};
240229
await this.persistence
@@ -253,7 +242,7 @@ export class SyncServices {
253242
async insertNewOrderers(orderer, channel_genesis_hash, client) {
254243
const network_id = client.getNetworkId();
255244
const discoveryProtocol = client.fabricGateway.getDiscoveryProtocol();
256-
const requesturl = `${discoveryProtocol}://${orderer.host}:${orderer.port}`;
245+
const requesturl = `${orderer.host}:${orderer.port}`;
257246
logger.debug(
258247
'insertNewOrderers discoveryProtocol ',
259248
discoveryProtocol,
@@ -263,8 +252,8 @@ export class SyncServices {
263252

264253
const orderer_row = {
265254
mspid: orderer.org_name,
266-
requests: requesturl.replace(/^grpcs*:\/\//, ''),
267-
server_hostname: orderer.host,
255+
requests: requesturl,
256+
server_hostname: requesturl,
268257
channel_genesis_hash,
269258
peer_type: 'ORDERER'
270259
};
@@ -351,11 +340,10 @@ export class SyncServices {
351340
channel_genesis_hash
352341
) {
353342
const network_id = client.getNetworkId();
354-
const host_port = endpoint.split(':');
355343
const chaincode_peer_row = {
356344
chaincodeid: chaincode.name,
357345
cc_version: chaincode.version,
358-
peerid: host_port[0],
346+
peerid: endpoint,
359347
channelid: channel_genesis_hash
360348
};
361349
await this.persistence

client/e2e-test/specs/dashboard/dashboard.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ function test() {
6565
const peerUrlStrList = peerUrlList.map((elm, idx, array) => {
6666
return elm.getText();
6767
});
68-
expect(peerUrlStrList).to.include('peer0-org1');
69-
expect(peerUrlStrList).to.include('peer1-org1');
70-
expect(peerUrlStrList).to.include('peer0-org2');
71-
expect(peerUrlStrList).to.include('orderer0-ordererorg1');
72-
expect(peerUrlStrList).to.include('orderer1-ordererorg1');
68+
expect(peerUrlStrList).to.include('peer0-org1:31000');
69+
expect(peerUrlStrList).to.include('peer1-org1:31001');
70+
expect(peerUrlStrList).to.include('peer0-org2:31002');
71+
expect(peerUrlStrList).to.include('orderer0-ordererorg1:30000');
72+
expect(peerUrlStrList).to.include('orderer1-ordererorg1:30001');
7373
});
7474
});
7575

client/e2e-test/specs/network/network_view.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ function test() {
2626
const nodeStrList = nodeLists.map((elm, idx, array) => {
2727
return elm.getText();
2828
});
29-
expect(nodeStrList).to.include('peer0-org1');
30-
expect(nodeStrList).to.include('peer1-org1');
31-
expect(nodeStrList).to.include('peer0-org2');
32-
expect(nodeStrList).to.include('orderer0-ordererorg1');
33-
expect(nodeStrList).to.include('orderer1-ordererorg1');
29+
expect(nodeStrList).to.include('peer0-org1:31000');
30+
expect(nodeStrList).to.include('peer1-org1:31001');
31+
expect(nodeStrList).to.include('peer0-org2:31002');
32+
expect(nodeStrList).to.include('orderer0-ordererorg1:30000');
33+
expect(nodeStrList).to.include('orderer1-ordererorg1:30001');
3434
});
3535
});
3636
});

0 commit comments

Comments
 (0)