Files
hush3/src/metrics.h
Jack Grigg a6df7ab567 Add a persistent screen showing basic node metrics
The screen is implemented using ANSI Escape sequences.

Closes #1331
2016-10-22 15:50:06 -05:00

7.8 KiB

// Copyright (c) 2016 The Zcash developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
 
#include <atomic>
#include <string>
 
struct AtomicCounter {
std::atomic<int> value;
 
AtomicCounter() : value {0} { }
 
void increment(){
++value;
}
 
void decrement(){
--value;
}
 
int get(){
return value.load();
}
};
 
extern AtomicCounter transactionsValidated;
extern AtomicCounter ehSolverRuns;
extern AtomicCounter minedBlocks;
 
void ThreadShowMetricsScreen();
 
/**
* Heart image: https://commons.wikimedia.org/wiki/File:Heart_coraz%C3%B3n.svg
* License: CC BY-SA 3.0
*
* Rendering options:
* Zcash: img2txt -W 50 -H 26 -f utf8 -d none -g 0.7 Z-yellow.orange-logo.png
* Heart: img2txt -W 50 -H 26 -f utf8 -d none 2000px-Heart_corazón.svg.png
*/
const std::string METRICS_ART =
" \n"
" \n"
" .;tt;. .;t: :t;. \n"
" :8SX8S;;;:::t%8@S; .X ;S S; X. \n"
" t%Xt%%ttt@XXXX@::XXXX%XS t. X X .t \n"
" 8S;tttt%%tt8 @:;::XXXXXS8 X tt X \n"
" %S:;;;;:XXX@@8 S;8;;tt;XXXX%8 8 8 \n"
" 8S.:::;;% S:XXXXXX \n"
" 88....:::% %;::XXXX@ \n"
" S8888....:%;;;;;;;;; 8t;;;::XXX8 \n"
" S888888...:::;;;;tX8 ;Xtt;;;;;::XS. . . \n"
" t888888888....::::8 @:ttttt;;;;:::X % % \n"
" 888888888888...:SS %t%%%ttttt;;;;:X % % \n"
" 88888888888888.t. ;Stttt%%%ttttt;;;S % % \n"
" t888888888888S8 8X;;;tttt%%%tttt;;@ @ @ \n"
" @8888888888%% %%::::;;;tttt%%%tttt. S S \n"
" Stt88888888. %SSSSSSSSSStttt%%%tX S S \n"
" 8ttt8888S %;;tttt%S @ @ \n"
" 8%ttt88S %;;;;tt% 8 8 \n"
" %8ttttt@@@XXX@ %%%%%%%S::;;X8 %. .% \n"
" 88tttt888888 X8888....:S8 .; ;. \n"
" t8@ttt888@8888@888888S8S t t \n"
" :888St8888888%S88; S S \n"
" .;tt;: \n"
" \n"
" ";
 
const std::string OFFSET = " ";