diff options
| author | Bitflash <btf01@proton.me> | 2026-08-01 12:23:31 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-01 12:23:31 -0300 |
| commit | 24ed292f0524f1bc77c317b60d7ecf265596b3dd (patch) | |
| tree | acdbccfca6bc0725751af8e653c16b7797db8a3f /src/main.cpp | |
| parent | 64b9507846846e468ebba7e00fb59971edceca3b (diff) | |
diag: let the node say what is wrong with it (#81)
* Bump to 1.2.11
One change, and it is the reason a node on Windows kept collecting peers it
could not hear.
FD_SETSIZE was never defined in this tree, so it defaulted to 64 and select()
could watch the listen socket plus 63 peers -- everything past that stayed
connected and was never read again. Windows FD_SET stops adding once its array
is full and says nothing, so there was no error to notice. Because new
connections go on the end of vNodes, it was always the newest connection that
starved, including the ones dialed to fix connectivity.
Measured on two nodes: 277 and 90 CNode objects against 93 and 90 live
sockets, 316 and 355 sockets in a bound-but-never-connected state, and a status
bar reporting hundreds of peers for a node really talking to thirty.
1.2.11 raises FD_SETSIZE to 1024 on Windows, caps connections at 125, drops a
node stuck undeliverable after 60 seconds instead of holding it forever, stops
answering a failed select() with POSIX code that has no meaning on Windows, and
warns when there are more peers than select can watch.
* diag: let the node say what is wrong with it
Every hard problem in this project so far was found from outside the node --
sockets read over WMI, committed memory compared against a README, a grep over
somebody debug.log. In each case the node knew and had no way to say so.
One report, rendered identically for the GUI panel and the log: peers held vs
peers actually watched by select(), blocks received and how many arrived without
a parent, proof-of-work mode with the live miner thread count, and per peer the
age of the last message in each direction plus anything stuck unsent.
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 5610de9..1a4c9ea 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
| @@ -1494,6 +1494,11 @@ bool CBlock::AcceptBlock() | |||
| 1494 | 1494 | ||
| 1495 | bool ProcessBlock(CNode* pfrom, CBlock* pblock) | 1495 | bool ProcessBlock(CNode* pfrom, CBlock* pblock) |
| 1496 | { | 1496 | { |
| 1497 | // Counted before any check, so the ratio below is against everything that | ||
| 1498 | // arrived rather than everything that was any good. | ||
| 1499 | if (pfrom) | ||
| 1500 | nBlocksReceived++; | ||
| 1501 | |||
| 1497 | // Check for duplicate | 1502 | // Check for duplicate |
| 1498 | uint256 hash = pblock->GetHash(); | 1503 | uint256 hash = pblock->GetHash(); |
| 1499 | if (mapBlockIndex.count(hash)) | 1504 | if (mapBlockIndex.count(hash)) |
| @@ -1512,6 +1517,8 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) | |||
| 1512 | if (!mapBlockIndex.count(pblock->hashPrevBlock)) | 1517 | if (!mapBlockIndex.count(pblock->hashPrevBlock)) |
| 1513 | { | 1518 | { |
| 1514 | printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().substr(0,14).c_str()); | 1519 | printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().substr(0,14).c_str()); |
| 1520 | if (pfrom) | ||
| 1521 | nBlocksWithoutParent++; | ||
| 1515 | mapOrphanBlocks.insert(make_pair(hash, pblock)); | 1522 | mapOrphanBlocks.insert(make_pair(hash, pblock)); |
| 1516 | mapOrphanBlocksByPrev.insert(make_pair(pblock->hashPrevBlock, pblock)); | 1523 | mapOrphanBlocksByPrev.insert(make_pair(pblock->hashPrevBlock, pblock)); |
| 1517 | 1524 | ||