-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTUI_Block.cpp
More file actions
29 lines (24 loc) · 869 Bytes
/
Copy pathTUI_Block.cpp
File metadata and controls
29 lines (24 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "TUI_Block.h"
TUI_Block::TUI_Block(Block block, int start_x, int start_y, int id) {
this->block = block;
this->start_x = start_x;
this->start_y = start_y;
this->id = id;
}
void TUI_Block::make_window() { win = newwin(8, 79, start_y, start_x); }
void TUI_Block::fill_window() {
box(win, 0, 0);
mvwprintw(win, 0, 2, "Block #%d", id);
mvwprintw(win, 2, 2, "Timestamp: %d", block.timestamp);
mvwprintw(win, 3, 2, "Nonce: %d", block.pivot);
mvwprintw(win, 4, 2, "Data: %s", block.data);
mvwprintw(win, 5, 2, "Prev Hash: ");
print_hash(win, block.prev_hash);
mvwprintw(win, 6, 2, "Hash: ");
print_hash(win, block.hash);
}
void TUI_Block::refresh_window() { wrefresh(win); }
void TUI_Block::print_hash(WINDOW *win, char *hash) {
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
wprintw(win, "%.2x", hash[i] & 0xFF);
}