upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorbitflash-maintainer <noreply@bitflash.invalid>2026-09-02 05:31:22 +0000
committerbitflash-maintainer <noreply@bitflash.invalid>2026-09-02 05:31:22 +0000
commit2661de141e46dadfb2903bb12e72dc87c5a64375 (patch)
tree73f5492187a1da4b362463834983ad767f105306 /src/net.h
parentae1c6a7b49d9b4f8cf7218c0baec84f348eb5ef6 (diff)
log: demote the four lines that were 90% of debug.log behind /debugrelay
A 13-hour production capture was ~71% "sending: tx", ~16% "Nostr: discovered .btf peer", ~5% "Relaying wtx", and ~43% of raw lines were CBlock/CTransaction dumps -- all already under -debug, which operators run permanently, so -debug was useless as a filter. The category mechanism gains a verbose tier: "relay" and "nostrdiscovery" are accepted only with the new /debugrelay flag (which implies /debug); everything else keeps its current gate. Demoted, with message text unchanged for anyone grepping it: net.h "sending: tx (N bytes)" (BeginMessage/EndMessage/ AbortMessage all pick the category from the command, so no orphaned "(N bytes)" fragments leak into a plain -debug log) main.cpp "Relaying wtx", "received block:" + CBlock::print, and the BitcoinMiner block dump nostr.cpp "Nostr: discovered .btf peer" -> "nostrdiscovery" Pool/worker/payout, [payout], BLOCK ORPHANED/ACCEPTED and share flow lines are untouched. Because LogPrint dedup keys on category, demoted lines also keep their burst collapse under /debugrelay. Closes #35
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/net.h b/src/net.h
index 9f3c7e4..1aee973 100644
--- a/src/net.h
+++ b/src/net.h
@@ -802,6 +802,18 @@ public:
802 802
803 803
804 804
805 // "sending: tx (N bytes)" alone was ~71% of a 13-hour production
806 // debug.log (issue #35), so tx sends are demoted to the /debugrelay-gated
807 // "relay" category; every other command's send trace stays on "net".
808 // The line is emitted in pieces across BeginMessage/EndMessage/
809 // AbortMessage, so all three must agree on the category or orphaned
810 // "(N bytes)" fragments would leak into a plain -debug log.
811 // Valid only mid-message (nPushPos != -1).
812 const char* SendLogCategory() const
813 {
814 return strcmp(GetMessageCommand(), "tx") == 0 ? "relay" : "net";
815 }
816
805 void BeginMessage(const char* pszCommand) 817 void BeginMessage(const char* pszCommand)
806 { 818 {
807 EnterCriticalSection(&cs_vSend); 819 EnterCriticalSection(&cs_vSend);
@@ -809,17 +821,19 @@ public:
809 AbortMessage(); 821 AbortMessage();
810 nPushPos = vSend.size(); 822 nPushPos = vSend.size();
811 vSend << CMessageHeader(pszCommand, 0); 823 vSend << CMessageHeader(pszCommand, 0);
812 if (LogAcceptsCategory("net")) printf("sending: %-12s ", pszCommand); 824 if (LogAcceptsCategory(SendLogCategory())) printf("sending: %-12s ", pszCommand);
813 } 825 }
814 826
815 void AbortMessage() 827 void AbortMessage()
816 { 828 {
817 if (nPushPos == -1) 829 if (nPushPos == -1)
818 return; 830 return;
831 // Capture before nPushPos is cleared; GetMessageCommand() needs it.
832 const char* pszCategory = SendLogCategory();
819 vSend.resize(nPushPos); 833 vSend.resize(nPushPos);
820 nPushPos = -1; 834 nPushPos = -1;
821 LeaveCriticalSection(&cs_vSend); 835 LeaveCriticalSection(&cs_vSend);
822 if (LogAcceptsCategory("net")) printf("(aborted)\n"); 836 if (LogAcceptsCategory(pszCategory)) printf("(aborted)\n");
823 } 837 }
824 838
825 void EndMessage() 839 void EndMessage()
@@ -839,10 +853,10 @@ public:
839 unsigned int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader); 853 unsigned int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader);
840 memcpy((char*)&vSend[nPushPos] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize)); 854 memcpy((char*)&vSend[nPushPos] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize));
841 855
842 if (LogAcceptsCategory("net")) printf("(%d bytes) ", nSize); 856 if (LogAcceptsCategory(SendLogCategory())) printf("(%d bytes) ", nSize);
843 //for (int i = nPushPos+sizeof(CMessageHeader); i < min(vSend.size(), nPushPos+sizeof(CMessageHeader)+20U); i++) 857 //for (int i = nPushPos+sizeof(CMessageHeader); i < min(vSend.size(), nPushPos+sizeof(CMessageHeader)+20U); i++)
844 // printf("%02x ", vSend[i] & 0xff); 858 // printf("%02x ", vSend[i] & 0xff);
845 if (LogAcceptsCategory("net")) printf("\n"); 859 if (LogAcceptsCategory(SendLogCategory())) printf("\n");
846 860
847 nPushPos = -1; 861 nPushPos = -1;
848 LeaveCriticalSection(&cs_vSend); 862 LeaveCriticalSection(&cs_vSend);