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:
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/net.h b/src/net.h
index f028c3b..7d70721 100644
--- a/src/net.h
+++ b/src/net.h
@@ -29,6 +29,21 @@ CNode* ConnectNodeBtfResolved(const string& strBtfAddr, const string& strMeeting
29void ThreadBtfAccept(void* parg); 29void ThreadBtfAccept(void* parg);
30void ThreadBtfConnect(void* parg); 30void ThreadBtfConnect(void* parg);
31extern string strBtfConnect; 31extern string strBtfConnect;
32
33// --- .btf peer exchange ---------------------------------------------------
34// Peers gossip signed descriptors so discovery survives a relay outage. Both
35// caps apply to a single "btfpeers" message; the generic header limit is 256 MB,
36// which is no protection at all for something a stranger can send unprompted.
37static const unsigned int MAX_PEX_DESCRIPTORS = 20;
38static const unsigned int MAX_PEX_DESCRIPTOR_BYTES = 1024;
39// Ignore a peer's exchange more often than this. One announcement per side per
40// connection is the intended traffic; anything faster is someone else's idea.
41static const int64 PEX_MIN_INTERVAL = 60;
42
43// Descriptors to hand a peer: ours first, then peers that answered us.
44void BtfPexCollect(std::vector<std::string>& vDescOut);
45// Verify descriptors a peer sent and remember the good ones. Returns how many.
46int BtfPexAccept(const std::vector<std::string>& vDesc);
32void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1); 47void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);
33bool AnySubscribed(unsigned int nChannel); 48bool AnySubscribed(unsigned int nChannel);
34void ThreadBitcoinMiner(void* parg); 49void ThreadBitcoinMiner(void* parg);
@@ -467,6 +482,9 @@ public:
467 // publish and subscription 482 // publish and subscription
468 vector<char> vfSubscribe; 483 vector<char> vfSubscribe;
469 484
485 // Last "btfpeers" we accepted from this node, to rate-limit the exchange.
486 int64 nLastPexRecv;
487
470 488
471 CNode(SOCKET hSocketIn, CAddress addrIn, bool fInboundIn=false) 489 CNode(SOCKET hSocketIn, CAddress addrIn, bool fInboundIn=false)
472 { 490 {
@@ -483,6 +501,7 @@ public:
483 fDisconnect = false; 501 fDisconnect = false;
484 nRefCount = 0; 502 nRefCount = 0;
485 nReleaseTime = 0; 503 nReleaseTime = 0;
504 nLastPexRecv = 0;
486 vfSubscribe.assign(256, false); 505 vfSubscribe.assign(256, false);
487 506
488 // Push a version message 507 // Push a version message