diff options
Diffstat (limited to 'src/net.h')
| -rw-r--r-- | src/net.h | 32 |
1 files changed, 32 insertions, 0 deletions
| @@ -51,6 +51,24 @@ static const int64 PEX_MIN_INTERVAL = 60; | |||
| 51 | // traffic is nothing: one per relay per five minutes. | 51 | // traffic is nothing: one per relay per five minutes. |
| 52 | static const int BTF_RENDEZVOUS_WAIT_SECS = 300; | 52 | static const int BTF_RENDEZVOUS_WAIT_SECS = 300; |
| 53 | 53 | ||
| 54 | // Liveness of an established peer connection. BTF_RENDEZVOUS_WAIT_SECS bounds | ||
| 55 | // the wait for a dial to arrive; these bound the connection that comes out of | ||
| 56 | // it, which has the same failure mode once it goes quiet. | ||
| 57 | // | ||
| 58 | // A healthy peer relays a block inventory roughly every nTargetSpacing (two | ||
| 59 | // minutes), so silence measured in block intervals is the honest signal. | ||
| 60 | // Bitcoin used ninety minutes against ten-minute blocks -- nine intervals -- | ||
| 61 | // and the same nine intervals here is eighteen minutes; thirty leaves margin | ||
| 62 | // for a slow stretch without letting a dead path last an hour. | ||
| 63 | static const int BTF_RECV_TIMEOUT_SECS = 30 * 60; | ||
| 64 | static const int BTF_SEND_STALL_SECS = 10 * 60; | ||
| 65 | static const int BTF_HANDSHAKE_GRACE_SECS = 60; | ||
| 66 | |||
| 67 | // Send a ping after this long with nothing to say, so a peer running the | ||
| 68 | // inactivity check above does not mistake a quiet node for a dead one. Must | ||
| 69 | // stay well under BTF_RECV_TIMEOUT_SECS. | ||
| 70 | static const int BTF_PING_INTERVAL_SECS = 10 * 60; | ||
| 71 | |||
| 54 | // Descriptors to hand a peer: ours first, then peers that answered us. | 72 | // Descriptors to hand a peer: ours first, then peers that answered us. |
| 55 | void BtfPexCollect(std::vector<std::string>& vDescOut); | 73 | void BtfPexCollect(std::vector<std::string>& vDescOut); |
| 56 | // Verify descriptors a peer sent and remember the good ones. Returns how many. | 74 | // Verify descriptors a peer sent and remember the good ones. Returns how many. |
| @@ -500,6 +518,16 @@ public: | |||
| 500 | // Last "btfpeers" we accepted from this node, to rate-limit the exchange. | 518 | // Last "btfpeers" we accepted from this node, to rate-limit the exchange. |
| 501 | int64 nLastPexRecv; | 519 | int64 nLastPexRecv; |
| 502 | 520 | ||
| 521 | // Liveness. A peer whose network path dies silently -- NAT drops an idle | ||
| 522 | // mapping, a relay restarts, a route changes -- never sends FIN, so the | ||
| 523 | // socket stays readable-never and the node simply stops hearing from it | ||
| 524 | // with no error anywhere. These stamps are the only way to tell that | ||
| 525 | // apart from a peer that merely has nothing to say. | ||
| 526 | int64 nTimeConnected; | ||
| 527 | int64 nLastSend; | ||
| 528 | int64 nLastRecv; | ||
| 529 | int64 nLastSendEmpty; | ||
| 530 | |||
| 503 | 531 | ||
| 504 | CNode(SOCKET hSocketIn, CAddress addrIn, bool fInboundIn=false) | 532 | CNode(SOCKET hSocketIn, CAddress addrIn, bool fInboundIn=false) |
| 505 | { | 533 | { |
| @@ -517,6 +545,10 @@ public: | |||
| 517 | nRefCount = 0; | 545 | nRefCount = 0; |
| 518 | nReleaseTime = 0; | 546 | nReleaseTime = 0; |
| 519 | nLastPexRecv = 0; | 547 | nLastPexRecv = 0; |
| 548 | nTimeConnected = GetTime(); | ||
| 549 | nLastSend = 0; | ||
| 550 | nLastRecv = 0; | ||
| 551 | nLastSendEmpty = GetTime(); | ||
| 520 | vfSubscribe.assign(256, false); | 552 | vfSubscribe.assign(256, false); |
| 521 | 553 | ||
| 522 | // Push a version message | 554 | // Push a version message |