@@ -187,7 +187,6 @@ function doRequest(server, first) {
187187function doQueryWallet ( ) {
188188 if ( config . wallet_ip && config . wallet_ip !== '' )
189189 {
190-
191190 const url = `http://${ config . wallet_ip } :${ config . wallet_port } ` ;
192191 const json = {
193192 jsonrpc : '2.0' ,
@@ -212,6 +211,25 @@ function doQueryWallet() {
212211 }
213212 }
214213 ) ;
214+
215+ json . method = 'getblockcount' ;
216+ req . post ( url , { json} ,
217+ function ( error , response , body ) {
218+ if ( ! error && response . statusCode == 200 ) {
219+ all . block_count = body . result ;
220+ }
221+ }
222+ ) ;
223+
224+ json . method = 'getblocks' ;
225+ json . params . last = "1" ;
226+ req . post ( url , { json} ,
227+ function ( error , response , body ) {
228+ if ( ! error && response . statusCode == 200 ) {
229+ all . last_block = body . result [ 0 ] ;
230+ }
231+ }
232+ ) ;
215233 }
216234
217235}
@@ -243,7 +261,9 @@ let all = {
243261 good : 0 ,
244262 bad : 0 ,
245263 balance : 0 ,
246- accounts : 0
264+ accounts : 0 ,
265+ block_count : 0 ,
266+ last_block : null
247267} ;
248268
249269Object . keys ( config . servers ) . forEach ( ( ident ) => {
@@ -391,16 +411,24 @@ function print() {
391411 }
392412 } ) ;
393413
394- let header = ' ' + clc . underline ( 'rhmonitor by @techworker' ) + "\n" ;
395- header += ' Av: ' + Object . keys ( servers ) . length + '/' + clc . bgGreen . white ( all . good ) + '/' + clc . bgRed . white ( all . bad ) ;
414+
415+ let header = "\n" + ' Av: ' + Object . keys ( servers ) . length + '/' + clc . bgGreen . white ( all . good ) + '/' + clc . bgRed . white ( all . bad ) ;
396416 header += ' Thr: ' + all . threads ;
397417 header += ' Sp: ' + all . speed + ' H/s' ;
398418 header += ' Acc/Rej: ' + all . accepted + '/' + all . rejected ;
399419 header += ' PASC: ' + all . balance ;
400420 header += ' Acc: ' + all . accounts ;
401421 //process.exit();
402422 output = header + "\n" + output ;
403- output += format ( "You like what you see? Donate to 3450-25" , true , 78 ) ;
423+ output += format ( " Block: " + all . block_count . toString ( ) , false , 20 ) ;
424+
425+ if ( all . last_block !== null ) {
426+ output += format ( ` Last: ${ all . last_block . block } ${ all . last_block . payload } - ${ all . last_block . hashratekhs } KH/s` , false , 61 ) + "\n" ;
427+ }
428+
429+ output += ' ────────────────────────────────────────────────────────────────────────────────' + "\n" ;
430+ output += " rhmonitor by @techworker" ;
431+ output += format ( "You like what you see? Donate to 3450-25" , true , 56 ) + "\n" ;
404432
405433
406434 console . log ( output ) ;
0 commit comments