Skip to content
This repository was archived by the owner on Oct 19, 2022. It is now read-only.

Commit 958bb33

Browse files
committed
fix error node_id
1 parent d5c2dc4 commit 958bb33

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const firebase = require('firebase');
2525
});
2626
var while_loop_round = 0;
2727
while (true) {
28-
while_loop_round += 1;
2928
var resource_node_list = null;
3029
const node_list_file = 'node_list.txt';
3130
if (existsSync(node_list_file)) {
@@ -68,19 +67,21 @@ const firebase = require('firebase');
6867

6968
const filter_node_conn = lodash.filter(JSON.parse(JSON.stringify(await fullNode.getConnections())), obj_item => obj_item.type !== 1);
7069

71-
for (const property in filter_node_conn) {
72-
try {
73-
const closeNodeConnection = await fullNode.closeNodeConnection({
74-
node_id: filter_node_conn[property].node_id
75-
});
76-
} catch (exception) {
77-
console.log(exception);
70+
if (Object.keys(filter_node_conn).length > 0) {
71+
for (const property in filter_node_conn) {
72+
try {
73+
const closeNodeConnection = await fullNode.closeNodeConnection({
74+
node_id: filter_node_conn[property].node_id
75+
});
76+
} catch (exception) {
77+
console.log(exception);
78+
}
7879
}
7980
}
8081

8182
if (while_loop_round % 100 == 0) {
8283
if (resource_node_list == 'node_list_firebase') {
83-
const currConnections = lodash.filter(JSON.parse(JSON.stringify(await fullNode.getConnections())), obj_item => obj_item.type === 1);
84+
const currConnections = lodash.filter(JSON.parse(JSON.stringify(await fullNode.getConnections())['connections']), obj_item => obj_item.type === 1);
8485
for (const property in currConnections) {
8586
const newChiaNode = await app.firestore().collection('node_list').doc().set({
8687
node_ip: currConnections[property].peer_host,
@@ -89,5 +90,6 @@ const firebase = require('firebase');
8990
}
9091
}
9192
}
93+
while_loop_round += 1;
9294
}
9395
})();

0 commit comments

Comments
 (0)