@@ -25,7 +25,6 @@ const firebase = require('firebase');
25
25
} ) ;
26
26
var while_loop_round = 0 ;
27
27
while ( true ) {
28
- while_loop_round += 1 ;
29
28
var resource_node_list = null ;
30
29
const node_list_file = 'node_list.txt' ;
31
30
if ( existsSync ( node_list_file ) ) {
@@ -68,19 +67,21 @@ const firebase = require('firebase');
68
67
69
68
const filter_node_conn = lodash . filter ( JSON . parse ( JSON . stringify ( await fullNode . getConnections ( ) ) ) , obj_item => obj_item . type !== 1 ) ;
70
69
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
+ }
78
79
}
79
80
}
80
81
81
82
if ( while_loop_round % 100 == 0 ) {
82
83
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 ) ;
84
85
for ( const property in currConnections ) {
85
86
const newChiaNode = await app . firestore ( ) . collection ( 'node_list' ) . doc ( ) . set ( {
86
87
node_ip : currConnections [ property ] . peer_host ,
@@ -89,5 +90,6 @@ const firebase = require('firebase');
89
90
}
90
91
}
91
92
}
93
+ while_loop_round += 1 ;
92
94
}
93
95
} ) ( ) ;
0 commit comments