Browse Source

Display tail end of prevblock hash rather than start+32bits

Luke Dashjr 13 years ago
parent
commit
9bbf037c39
2 changed files with 7 additions and 5 deletions
  1. 1 1
      README
  2. 6 4
      miner.c

+ 1 - 1
README

@@ -458,7 +458,7 @@ there to cope with future improvements in hardware.
 
 
 The block display shows:
-Block: 00000209... #217360  Diff:2.98M  Started: [17:17:22]  Best share: 2.71K
+Block: ...1b89f8d3 #217364  Diff:2.98M  Started: [17:17:22]  Best share: 2.71K
 
 This shows a short stretch of the current block, the next block's height and
 difficulty, when the search for the new block started, and the all time best

+ 6 - 4
miner.c

@@ -1688,11 +1688,13 @@ static char *workpadding = "0000008000000000000000000000000000000000000000000000
 static
 void __update_block_title(const unsigned char *hash_swap)
 {
+	char *tmp;
 	if (hash_swap) {
 		// Only provided when the block has actually changed
 		free(current_hash);
-		current_hash = bin2hex(&hash_swap[4], 8);
-		current_hash = realloc_strcat(current_hash, "...");
+		current_hash = malloc(3 /* ... */ + 16 /* block hash segment */);
+		tmp = bin2hex(&hash_swap[24], 8);
+		sprintf(current_hash, "...%s", tmp);
 		known_blkheight_current = false;
 	} else if (likely(known_blkheight_current)) {
 		return;
@@ -1700,8 +1702,8 @@ void __update_block_title(const unsigned char *hash_swap)
 	if (current_block_id == known_blkheight_blkid) {
 		// FIXME: The block number will overflow this sometime around AD 2025-2027
 		if (known_blkheight < 1000000) {
-			memcpy(&current_hash[8], "... #", 5);
-			sprintf(&current_hash[13], "%6u", known_blkheight);
+			memmove(&current_hash[3], &current_hash[11], 8);
+			sprintf(&current_hash[11], " #%6u", known_blkheight);
 		}
 		known_blkheight_current = true;
 	}