added invariant checks for peer_counter in block_info. added bytes_progress and block_size to block_info (to allow a more detail download progress display). Updated client_test to show download progress per block and also to have a separate color for 'multi blocks' (i.e. blocks that have been requested from more than one peer)

This commit is contained in:
Arvid Norberg
2007-07-08 20:45:42 +00:00
parent e395747e35
commit 4771f323f6
5 changed files with 73 additions and 11 deletions

View File

@@ -1023,17 +1023,19 @@ int main(int ac, char* av[])
{
int index = peer_index(i->blocks[j].peer, peers);
char str[] = "+";
bool currently_downloading = false;
if (index >= 0)
{
str[0] = (index < 10)?'0' + index:'A' + index - 10;
currently_downloading = peers[index].downloading_piece_index == i->piece_index
&& peers[index].downloading_block_index == j;
}
#ifdef ANSI_TERMINAL_COLORS
if (currently_downloading)
out << esc("33;7") << str << esc("0");
if (i->blocks[j].bytes_progress > 0
&& i->blocks[j].state == block_info::requested)
{
if (i->blocks[j].num_peers > 1)
out << esc("1;7");
else
out << esc("33;7");
out << to_string(i->blocks[j].bytes_progress / float(i->blocks[j].block_size) * 10, 1) << esc("0");
}
else if (i->blocks[j].state == block_info::finished) out << esc("32;7") << str << esc("0");
else if (i->blocks[j].state == block_info::writing) out << esc("35;7") << str << esc("0");
else if (i->blocks[j].state == block_info::requested) out << str;