upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authorBitflash <btf01@proton.me>2026-07-28 15:25:29 -0300
committerGitHub <noreply@github.com>2026-07-28 15:25:29 -0300
commit8770e49d5264bdc9f6daec61dee74ca74dabdc0a (patch)
tree7899739b6619ee355cedda188b58baf9aacdb6c4 /src/main.h
parent1635bc34f40c76ac2943dbe6ff15dd0180b62ea6 (diff)
main: cap orphan transactions held in memory (#16)
A transaction naming a parent the node does not have is never validated, just stored in mapOrphanTransactions -- and there was no ceiling. Sending them costs a peer nothing: no proof of work, no valid signature, no fee, and the node keeps every one. Any peer could grow that map until the node died of memory exhaustion. Cap at 100, evicting at random rather than in map order so an attacker cannot keep its own orphans resident by choosing hashes that sort low. Local policy, not consensus -- no effect on block or transaction validity.
Diffstat (limited to 'src/main.h')
-rw-r--r--src/main.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main.h b/src/main.h
index 533974c..40f8d45 100644
--- a/src/main.h
+++ b/src/main.h
@@ -15,6 +15,9 @@ class CWalletTx;
15class CKeyItem; 15class CKeyItem;
16 16
17static const unsigned int MAX_SIZE = 0x02000000; 17static const unsigned int MAX_SIZE = 0x02000000;
18// Ceiling on transactions held waiting for a parent that has not arrived.
19// They cost a peer nothing to send and are never validated, only stored.
20static const unsigned int MAX_ORPHAN_TRANSACTIONS = 100;
18static const int64 COIN = 100000000; 21static const int64 COIN = 100000000;
19// Total Bitflash emission: identical to Bitcoin (21 million). 22// Total Bitflash emission: identical to Bitcoin (21 million).
20// MAX_MONEY guards against the value overflow bug (CVE-2010-5139), which in 23// MAX_MONEY guards against the value overflow bug (CVE-2010-5139), which in
@@ -106,6 +109,9 @@ void ReacceptWalletTransactions();
106void RelayWalletTransactions(); 109void RelayWalletTransactions();
107bool LoadBlockIndex(bool fAllowNew=true); 110bool LoadBlockIndex(bool fAllowNew=true);
108void PrintBlockTree(); 111void PrintBlockTree();
112void AddOrphanTx(const CDataStream& vMsg);
113void EraseOrphanTx(uint256 hash);
114void LimitOrphanTx(unsigned int nMaxOrphans);
109bool BitcoinMiner(); 115bool BitcoinMiner();
110void ThreadRPCServer(void* parg); // rpc.cpp -- .btf pool server 116void ThreadRPCServer(void* parg); // rpc.cpp -- .btf pool server
111void GetParticipantMiningStats(uint64& sharesSent, uint64& sharesAccepted, double& hashRate); 117void GetParticipantMiningStats(uint64& sharesSent, uint64& sharesAccepted, double& hashRate);