|
|
@ -93,6 +93,14 @@ void interactiveHelp() |
|
|
|
<< " exit Exits the application." << endl; |
|
|
|
} |
|
|
|
|
|
|
|
void credits() |
|
|
|
{ |
|
|
|
cout |
|
|
|
<< "Ethereum (++) " << ETH_QUOTED(ETH_VERSION) << endl |
|
|
|
<< " Code by Gav Wood, (c) 2013, 2014." << endl |
|
|
|
<< " Based on a design by Vitalik Buterin." << endl << endl; |
|
|
|
} |
|
|
|
|
|
|
|
void version() |
|
|
|
{ |
|
|
|
cout << "eth version " << ETH_QUOTED(ETH_VERSION) << endl; |
|
|
@ -186,13 +194,18 @@ int nc_window_streambuf::overflow( int c ) |
|
|
|
int ret = c; |
|
|
|
if (c != EOF) |
|
|
|
{ |
|
|
|
int x = 0; |
|
|
|
int y = 0; |
|
|
|
int x = 0, y = 0, mx = 0, my = 0; |
|
|
|
getyx(m_pnl, y, x); |
|
|
|
getmaxyx(m_pnl, my, mx); |
|
|
|
if (y < 1) |
|
|
|
y = 1; |
|
|
|
if (x < 2) |
|
|
|
x = 2; |
|
|
|
if (x > mx - 4) |
|
|
|
{ |
|
|
|
y++; |
|
|
|
x = 2; |
|
|
|
} |
|
|
|
if (m_flags) |
|
|
|
{ |
|
|
|
wattron(m_pnl, m_flags); |
|
|
@ -332,18 +345,17 @@ int main(int argc, char** argv) |
|
|
|
if (!clientName.empty()) |
|
|
|
clientName += "/"; |
|
|
|
Client c("Ethereum(++)/" + clientName + "v" ETH_QUOTED(ETH_VERSION) "/" ETH_QUOTED(ETH_BUILD_TYPE) "/" ETH_QUOTED(ETH_BUILD_PLATFORM), coinbase, dbPath); |
|
|
|
credits(); |
|
|
|
|
|
|
|
if (interactive) |
|
|
|
{ |
|
|
|
g_logPost = std::function<void(std::string const&, char const*)>(); |
|
|
|
/* cout << "Ethereum (++)" << endl;
|
|
|
|
cout << " Code by Gav Wood, (c) 2013, 2014." << endl; |
|
|
|
cout << " Based on a design by Vitalik Buterin." << endl << endl; |
|
|
|
*/ |
|
|
|
std::ostringstream ccout; |
|
|
|
|
|
|
|
/* Initialize ncurses */ |
|
|
|
const char* chr; |
|
|
|
char* str = new char[255]; |
|
|
|
int termwidth, termheight; |
|
|
|
int width, height; |
|
|
|
int y = 0, x = 2; |
|
|
|
std::string cmd; |
|
|
|
WINDOW * mainwin, * consolewin, * logwin, * blockswin, * pendingwin, * contractswin, * peerswin; |
|
|
|
|
|
|
@ -353,8 +365,8 @@ int main(int argc, char** argv) |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
getmaxyx(mainwin, termheight, termwidth); |
|
|
|
int width = termwidth, height = termheight; |
|
|
|
getmaxyx(mainwin, height, width); |
|
|
|
int qwidth = width / 4 - 4; |
|
|
|
|
|
|
|
nonl(); |
|
|
|
nocbreak(); |
|
|
@ -368,27 +380,25 @@ int main(int argc, char** argv) |
|
|
|
g_logVerbosity = 1; // Force verbosity level for now
|
|
|
|
|
|
|
|
consolewin = newwin(height * 3 / 5, width / 4, 0, 0); |
|
|
|
nc::nc_window_streambuf coutbuf( consolewin, ccout ); |
|
|
|
blockswin = newwin(height * 3 / 5, width / 4, 0, width / 4); |
|
|
|
pendingwin = newwin(height * 1 / 5, width / 4, 0, width * 2 / 4); |
|
|
|
peerswin = newwin(height * 2 / 5, width / 4, height * 1 / 5, width * 2 / 4); |
|
|
|
contractswin = newwin(height * 3 / 5, width / 4, 0, width * 3 / 4); |
|
|
|
|
|
|
|
wsetscrreg(consolewin, 1, height * 3 / 5 - 2); |
|
|
|
wsetscrreg(blockswin, 1, height * 3 / 5 - 2); |
|
|
|
wsetscrreg(pendingwin, 1, height * 1 / 5 - 2); |
|
|
|
wsetscrreg(peerswin, 1, height * 2 / 5 - 2); |
|
|
|
wsetscrreg(contractswin, 1, height * 3 / 5 - 2); |
|
|
|
|
|
|
|
mvwaddnstr(consolewin, 4, 2, "Ethereum (++) " ETH_QUOTED(ETH_VERSION) "\n", width / 4 - 4); |
|
|
|
mvwaddnstr(consolewin, 5, 2, " Code by Gav Wood, (c) 2013, 2014.\n", width / 4 - 4); |
|
|
|
mvwaddnstr(consolewin, 6, 2, " Based on a design by Vitalik Buterin.\n", width / 4 - 4); |
|
|
|
int vl = height * 3 / 5 - 4; |
|
|
|
wsetscrreg(consolewin, 1, vl); |
|
|
|
wsetscrreg(blockswin, 1, vl); |
|
|
|
wsetscrreg(pendingwin, 1, vl); |
|
|
|
wsetscrreg(peerswin, 1, vl); |
|
|
|
wsetscrreg(contractswin, 1, vl); |
|
|
|
|
|
|
|
mvwaddnstr(consolewin, 7, 2, "Type 'netstart 30303' to start networking", width / 4 - 4); |
|
|
|
mvwaddnstr(consolewin, 8, 2, "Type 'connect 54.201.28.117 30303' to connect", width / 4 - 4); |
|
|
|
mvwaddnstr(consolewin, 9, 2, "Type 'exit' to quit", width / 4 - 4); |
|
|
|
|
|
|
|
mvwprintw(mainwin, 1, 2, "> "); |
|
|
|
credits(); |
|
|
|
ccout << "Type 'netstart 30303' to start networking" << endl; |
|
|
|
ccout << "Type 'connect 54.201.28.117 30303' to connect" << endl; |
|
|
|
ccout << "Type 'exit' to quit" << endl; |
|
|
|
|
|
|
|
mvwprintw(mainwin, 1, x, "> "); |
|
|
|
wresize(mainwin, 3, width); |
|
|
|
mvwin(mainwin, height - 3, 0); |
|
|
|
|
|
|
@ -399,45 +409,14 @@ int main(int argc, char** argv) |
|
|
|
|
|
|
|
while (true) |
|
|
|
{ |
|
|
|
int y = 0; |
|
|
|
getmaxyx(mainwin, height, width); |
|
|
|
qwidth = width / 4 - 4; |
|
|
|
|
|
|
|
wclrtobot(consolewin); |
|
|
|
wclrtobot(pendingwin); |
|
|
|
wclrtobot(peerswin); |
|
|
|
wclrtobot(contractswin); |
|
|
|
|
|
|
|
box(mainwin, 0, 0); |
|
|
|
box(blockswin, 0, 0); |
|
|
|
box(pendingwin, 0, 0); |
|
|
|
box(peerswin, 0, 0); |
|
|
|
box(consolewin, 0, 0); |
|
|
|
box(contractswin, 0, 0); |
|
|
|
|
|
|
|
mvwprintw(blockswin, 0, 2, "Blocks"); |
|
|
|
mvwprintw(pendingwin, 0, 2, "Pending"); |
|
|
|
mvwprintw(contractswin, 0, 2, "Contracts"); |
|
|
|
|
|
|
|
// Block
|
|
|
|
mvwprintw(consolewin, 0, 2, "Block # "); |
|
|
|
eth::uint n = c.blockChain().details().number; |
|
|
|
chr = toString(n).c_str(); |
|
|
|
mvwprintw(consolewin, 0, 10, chr); |
|
|
|
|
|
|
|
// Address
|
|
|
|
mvwprintw(consolewin, 1, 2, "Address: "); |
|
|
|
chr = toHex(us.address().asArray()).c_str(); |
|
|
|
mvwprintw(consolewin, 2, 2, chr); |
|
|
|
|
|
|
|
// Balance
|
|
|
|
mvwprintw(consolewin, height * 3 / 5 - 1, 2, "Balance: "); |
|
|
|
u256 balance = c.state().balance(us.address()); |
|
|
|
chr = toString(balance).c_str(); |
|
|
|
mvwprintw(consolewin, height * 3 / 5 - 1, 11, chr); |
|
|
|
|
|
|
|
// Peers
|
|
|
|
mvwprintw(peerswin, 0, 2, "Peers: "); |
|
|
|
chr = toString(c.peers().size()).c_str(); |
|
|
|
mvwprintw(peerswin, 0, 9, chr); |
|
|
|
|
|
|
|
// Prompt
|
|
|
|
wmove(mainwin, 1, 4); |
|
|
|
getstr(str); |
|
|
@ -446,15 +425,13 @@ int main(int argc, char** argv) |
|
|
|
istringstream iss(s); |
|
|
|
iss >> cmd; |
|
|
|
|
|
|
|
mvwprintw(mainwin, 1, 2, "> "); |
|
|
|
mvwprintw(mainwin, 1, x, "> "); |
|
|
|
clrtoeol(); |
|
|
|
|
|
|
|
if (s.length() > 1) |
|
|
|
{ |
|
|
|
mvwaddstr(consolewin, height * 3 / 5 - 3, 2, "> "); |
|
|
|
wclrtoeol(consolewin); |
|
|
|
mvwaddnstr(consolewin, height * 3 / 5 - 3, 4, str, width - 6); |
|
|
|
mvwaddch(consolewin, height * 3 / 5 - 3, width / 4 - 1, ACS_VLINE); |
|
|
|
ccout << "> "; |
|
|
|
ccout << str << endl; |
|
|
|
} |
|
|
|
|
|
|
|
if (cmd == "netstart") |
|
|
@ -478,31 +455,29 @@ int main(int argc, char** argv) |
|
|
|
c.stopMining(); |
|
|
|
else if (cmd == "address") |
|
|
|
{ |
|
|
|
mvwaddstr(consolewin, height * 3 / 5 - 3, 2, "Current address:\n"); |
|
|
|
mvwaddch(consolewin, height * 3 / 5 - 3, width / 4 - 1, ACS_VLINE); |
|
|
|
ccout << "Current address:" << endl; |
|
|
|
const char* addchr = toHex(us.address().asArray()).c_str(); |
|
|
|
mvwaddstr(consolewin, height * 3 / 5 - 2, 2, addchr); |
|
|
|
ccout << addchr << endl; |
|
|
|
} |
|
|
|
else if (cmd == "secret") |
|
|
|
{ |
|
|
|
mvwaddstr(consolewin, height * 3 / 5 - 4, 2, "Current secret:\n"); |
|
|
|
mvwaddch(consolewin, height * 3 / 5 - 3, width / 4 - 1, ACS_VLINE); |
|
|
|
ccout << "Current secret:" << endl; |
|
|
|
const char* addchr = toHex(us.secret().asArray()).c_str(); |
|
|
|
mvwaddstr(consolewin, height * 3 / 5 - 3, 2, addchr); |
|
|
|
ccout << addchr << endl; |
|
|
|
} |
|
|
|
else if (cmd == "block") |
|
|
|
{ |
|
|
|
eth::uint n = c.blockChain().details().number; |
|
|
|
mvwaddstr(consolewin, height * 3 / 5 - 1, 2, "Current block # "); |
|
|
|
ccout << "Current block #:" << endl; |
|
|
|
const char* addchr = toString(n).c_str(); |
|
|
|
waddstr(consolewin, addchr); |
|
|
|
ccout << addchr << endl; |
|
|
|
} |
|
|
|
else if (cmd == "balance") |
|
|
|
{ |
|
|
|
u256 balance = c.state().balance(us.address()); |
|
|
|
mvwaddstr(consolewin, height * 3 / 5 - 1, 2, "Current balance: "); |
|
|
|
ccout << "Current balance:" << endl; |
|
|
|
const char* addchr = toString(balance).c_str(); |
|
|
|
waddstr(consolewin, addchr); |
|
|
|
ccout << addchr << endl; |
|
|
|
} |
|
|
|
else if (cmd == "transact") |
|
|
|
{ |
|
|
@ -604,7 +579,7 @@ int main(int argc, char** argv) |
|
|
|
auto d = bc.details(h); |
|
|
|
std::string s = "# " + std::to_string(d.number) + ' ' + toString(h); // .abridged();
|
|
|
|
y += 1; |
|
|
|
mvwaddnstr(blockswin, y, 2, s.c_str(), width / 4 - 4); |
|
|
|
mvwaddnstr(blockswin, y, x, s.c_str(), qwidth); |
|
|
|
|
|
|
|
for (auto const& i: RLP(bc.block(h))[1]) |
|
|
|
{ |
|
|
@ -614,7 +589,7 @@ int main(int argc, char** argv) |
|
|
|
" " + toString(toHex(t.safeSender().asArray())) + " " + (st.isContractAddress(t.receiveAddress) ? '*' : '-') + "> " + toString(t.receiveAddress) + ": " + toString(formatBalance(t.value)) + " [" + toString((unsigned)t.nonce) + "]": |
|
|
|
" " + toString(toHex(t.safeSender().asArray())) + " +> " + toString(right160(t.sha3())) + ": " + toString(formatBalance(t.value)) + " [" + toString((unsigned)t.nonce) + "]"; |
|
|
|
y += 1; |
|
|
|
mvwaddnstr(blockswin, y, 2, ss.c_str(), width / 4 - 6); |
|
|
|
mvwaddnstr(blockswin, y, x, ss.c_str(), width / 4 - 6); |
|
|
|
if (y > height * 3 / 5 - 4) |
|
|
|
break; |
|
|
|
} |
|
|
@ -633,7 +608,7 @@ int main(int argc, char** argv) |
|
|
|
else |
|
|
|
ss = toString(toHex(t.safeSender().asArray())) + " +> " + toString(right160(t.sha3())) + ": " + toString(formatBalance(t.value)) + "[" + toString((unsigned)t.nonce) + "]"; |
|
|
|
y += 1; |
|
|
|
mvwaddnstr(pendingwin, y, 2, ss.c_str(), width / 4 - 6); |
|
|
|
mvwaddnstr(pendingwin, y, x, ss.c_str(), width / 4 - 6); |
|
|
|
if (y > height * 3 / 5 - 4) |
|
|
|
break; |
|
|
|
} |
|
|
@ -652,7 +627,7 @@ int main(int argc, char** argv) |
|
|
|
std::string ss; |
|
|
|
ss = toString(r) + " : " + toString(formatBalance(i.second)) + " [" + toString((unsigned)st.transactionsFrom(i.first)) + "]"; |
|
|
|
y += 1; |
|
|
|
mvwaddnstr(contractswin, y, 2, ss.c_str(), width / 4 - 5); |
|
|
|
mvwaddnstr(contractswin, y, x, ss.c_str(), width / 4 - 5); |
|
|
|
if (y > height * 3 / 5 - 4) |
|
|
|
break; |
|
|
|
} |
|
|
@ -668,11 +643,45 @@ int main(int argc, char** argv) |
|
|
|
{ |
|
|
|
pss = toString(chrono::duration_cast<chrono::milliseconds>(i.lastPing).count()) + " ms - " + i.host + ":" + toString(i.port) + " - " + i.clientVersion; |
|
|
|
y += 1; |
|
|
|
mvwaddnstr(peerswin, y, 2, pss.c_str(), width / 4 - 5); |
|
|
|
mvwaddnstr(peerswin, y, x, pss.c_str(), width / 4 - 5); |
|
|
|
if (y > height * 2 / 5 - 4) |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
// Address
|
|
|
|
ccout << "Address:" << endl; |
|
|
|
chr = toHex(us.address().asArray()).c_str(); |
|
|
|
ccout << chr << endl << endl; |
|
|
|
// wmove(consolewin, 3, x);
|
|
|
|
|
|
|
|
box(mainwin, 0, 0); |
|
|
|
box(blockswin, 0, 0); |
|
|
|
box(pendingwin, 0, 0); |
|
|
|
box(peerswin, 0, 0); |
|
|
|
box(consolewin, 0, 0); |
|
|
|
box(contractswin, 0, 0); |
|
|
|
|
|
|
|
mvwprintw(pendingwin, 0, x, "Pending"); |
|
|
|
mvwprintw(contractswin, 0, x, "Contracts"); |
|
|
|
|
|
|
|
// Block
|
|
|
|
mvwprintw(blockswin, 0, x, "Block # "); |
|
|
|
eth::uint n = c.blockChain().details().number; |
|
|
|
chr = toString(n).c_str(); |
|
|
|
mvwprintw(blockswin, 0, 10, chr); |
|
|
|
|
|
|
|
// Balance
|
|
|
|
mvwprintw(consolewin, height * 3 / 5 - 1, x, "Balance: "); |
|
|
|
u256 balance = c.state().balance(us.address()); |
|
|
|
chr = toString(balance).c_str(); |
|
|
|
mvwprintw(consolewin, height * 3 / 5 - 1, 11, chr); |
|
|
|
wmove(consolewin, y, x); |
|
|
|
|
|
|
|
// Peers
|
|
|
|
mvwprintw(peerswin, 0, x, "Peers: "); |
|
|
|
chr = toString(c.peers().size()).c_str(); |
|
|
|
mvwprintw(peerswin, 0, 9, chr); |
|
|
|
|
|
|
|
wrefresh(consolewin); |
|
|
|
wrefresh(blockswin); |
|
|
|
wrefresh(pendingwin); |
|
|
|