Commit graph

157 commits

Author SHA1 Message Date
Dan Raviv 6efc333ffe
Remove redundant explicitly defined copy ctors
CFeeRate and CTxMemPoolEntry have explicitly defined copy ctors which has
the same functionality as the implicit default copy ctors which would
have been generated otherwise.

Besides being redundant, it violates the rule of three
(see https://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming) ).
(Of course, the rule of three doesn't -really- cause a resource
management issue here, but the reason for that is exactly that there is
no need for an explicit copy ctor in the first place since no resources
are being managed).

CFeeRate has an explicitly defined copy ctor which has the same
functionality as the implicit default copy ctor which would have been
generated otherwise.

-----------------------------

Cherry-picked from: b426e2467

Note:
Solved conflict where upstream moved CFeeRate into ./policy/
whereas we still have it in amount.h/cpp on 1.14.
2021-08-28 21:07:58 +02:00
Ross Nicoll 9c3a11b248 Clean up RPC tests (#1465)
* Enable full block tests
* Fix invalidblocktest
* Move watch only address funding to immediately before it's used, so node 0 doesn't spend the output before it checks it later.
* Fix `fundrawtransaction` tests and sanitize fee calculation at the same time
* Correct resolution of chain parameters when validating tx inputs, especially from previous coinbase transactions
* Set block versions on full block tests so that the generated blocks are AuxPoW compatible
2018-09-19 22:11:47 +01:00
Ross Nicoll 7b81f4de0a Move COINBASE_MATURITY to the consensus parameters (#1426) 2018-09-19 21:09:16 +01:00
Suhas Daftuar d28d583820 Bugfix: PrioritiseTransaction updates the mempool tx counter
The mempool's nTransactionsUpdated is used by getblocktemplate
to trigger new invocations of CreateNewBlock().

Github-Pull: #10196
Rebased-From: 909306cde3770ed7019e7b635e24cedbd9de66ce
2017-04-19 20:10:02 +00:00
Suhas Daftuar ea060c7495
Bugfix: ancestor modifed fees were incorrect for descendants
If prioritisetransaction was called for a tx with in-mempool
descendants, the modified ancestor fee values for those descendants was
incorrect.

Github-Pull: #10144
Rebased-From: 9bef02e365
2017-04-05 08:37:12 +02:00
CryptAxe 00e623d0b8 [Trivial] Update comments referencing main.cpp 2017-02-16 13:52:38 +01:00
Pieter Wuille 923dc447ea
Merge #9578: Add missing mempool lock for CalculateMemPoolAncestors
003cd60 Add missing mempool lock for CalculateMemPoolAncestors (Matt Corallo)
2017-02-05 12:08:08 -08:00
Karl-Johan Alm b7b48c8bbd Refactor: Remove using namespace <xxx> from src/*.cpp. 2017-01-27 18:13:20 +09:00
Wladimir J. van der Laan ff25c32392 mempool: add notification for added/removed entries
Add notification signals to make it possible to subscribe to mempool
changes:

- NotifyEntryAdded(CTransactionRef)>
- NotifyEntryRemoved(CTransactionRef, MemPoolRemovalReason)>

Also add a mempool removal reason enumeration, which is passed to the
removed notification based on why the transaction was removed from
the mempool.
2017-01-23 15:43:22 -05:00
Matt Corallo 003cd60cc3 Add missing mempool lock for CalculateMemPoolAncestors 2017-01-20 18:11:24 -05:00
Wladimir J. van der Laan dd98f04538
Merge #9380: Separate different uses of minimum fees
eb30d1a Introduce -dustrelayfee (Alex Morcos)
7b1add3 Introduce -incrementalrelayfee (Alex Morcos)
daec955 Introduce -blockmintxfee (Alex Morcos)
2017-01-16 19:33:08 +01:00
Alex Morcos 7b1add3c28 Introduce -incrementalrelayfee 2017-01-16 08:39:03 -05:00
Suhas Daftuar fe7e593b24 Fix use-after-free in CTxMemPool::removeConflicts() 2017-01-10 15:21:21 -05:00
Alex Morcos ebafdcabb1 Pass pointers to existing CTxMemPoolEntries to fee estimation 2017-01-04 12:09:34 -05:00
Alex Morcos d825838e64 Always update fee estimates on new blocks.
All decisions about whether the transactions are valid data points are made at the time the transaction arrives. Updating on blocks all the time will now cause stale fee estimates to decay quickly when we restart a node.
2017-01-04 12:09:34 -05:00
Alex Morcos 6f06b268c1 rename bool to validFeeEstimate 2017-01-04 12:09:33 -05:00
Alex Morcos 84f7ab08d2 Remove member variable hadNoDependencies from CTxMemPoolEntry
Fee estimation can just check its own mapMemPoolTxs to determine the same information.  Note that now fee estimation for block processing must happen before those transactions are removed, but this shoudl be a speedup.
2017-01-04 12:09:33 -05:00
Wladimir J. van der Laan 1ce7ede2a9
Merge #9288: Fix a bug if the min fee is 0 for FeeFilterRounder
f8d43b8 Avoid rollingMinimumFeeRate never being able to decay below half (Alex Morcos)
eab8e1b fix a bug if the min fee is 0 for FeeFilterRounder (Alex Morcos)
2017-01-04 12:33:56 +01:00
Wladimir J. van der Laan 869781c51c
Merge #9283: A few more CTransactionRef optimizations
91335ba Remove unused MakeTransactionRef overloads (Pieter Wuille)
6713f0f Make FillBlock consume txn_available to avoid shared_ptr copies (Pieter Wuille)
62607d7 Convert COrphanTx to keep a CTransactionRef (Pieter Wuille)
c44e4c4 Make AcceptToMemoryPool take CTransactionRef (Pieter Wuille)
2017-01-04 12:23:10 +01:00
isle2983 27765b6403 Increment MIT Licence copyright header year on files modified in 2016
Edited via:

$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Pieter Wuille c44e4c467c Make AcceptToMemoryPool take CTransactionRef 2016-12-21 18:18:23 -08:00
Wladimir J. van der Laan 5a70572049
Merge #9262: Prefer coins that have fewer ancestors, sanity check txn before ATMP
cee1612 reduce number of lookups in TransactionWithinChainLimit (Gregory Sanders)
af9bedb Test for fix of txn chaining in wallet (Gregory Sanders)
5882c09 CreateTransaction: Don't return success with too-many-ancestor txn (Gregory Sanders)
0b2294a SelectCoinsMinConf: Prefer coins with fewer ancestors (Gregory Sanders)
2016-12-20 13:27:08 +01:00
Gregory Sanders cee16123f5 reduce number of lookups in TransactionWithinChainLimit 2016-12-19 20:51:34 -05:00
Gregory Sanders 0b2294a980 SelectCoinsMinConf: Prefer coins with fewer ancestors 2016-12-13 09:41:04 -05:00
Alex Morcos f8d43b8081 Avoid rollingMinimumFeeRate never being able to decay below half 2016-12-08 15:40:14 -05:00
Alex Morcos a874ab5ccf remove internal tracking of mempool conflicts for reporting to wallet 2016-12-05 13:41:25 -05:00
Alex Morcos bf663f8e93 remove external usage of mempool conflict tracking 2016-12-05 13:41:25 -05:00
Matt Corallo 76faa3cdfe Rename the remaining main.{h,cpp} to validation.{h,cpp} 2016-12-02 09:42:51 -08:00
Pieter Wuille b4e4ba475a Introduce convenience type CTransactionRef 2016-11-19 17:53:23 -08:00
Pieter Wuille 1662b437b3 Make CBlock::vtx a vector of shared_ptr<CTransaction> 2016-11-19 17:51:09 -08:00
Alex Morcos b2322e0fc6 Remove priority estimation 2016-11-07 13:22:34 +01:00
Pieter Wuille c3efb58622 Add feedelta to TxMempoolInfo 2016-10-30 23:12:09 -07:00
Pieter Wuille 4100499db4 Return shared_ptr<CTransaction> from mempool removes 2016-10-21 19:22:43 -07:00
Pieter Wuille 51f278329d Make removed and conflicted arguments optional to remove 2016-10-21 19:22:43 -07:00
Pieter Wuille f48211b700 Bypass removeRecursive in removeForReorg 2016-10-21 19:22:43 -07:00
Wladimir J. van der Laan 5eaaa83ac1 Kill insecure_random and associated global state
There are only a few uses of `insecure_random` outside the tests.
This PR replaces uses of insecure_random (and its accompanying global
state) in the core code with an FastRandomContext that is automatically
seeded on creation.

This is meant to be used for inner loops. The FastRandomContext
can be in the outer scope, or the class itself, then rand32() is used
inside the loop. Useful e.g. for pushing addresses in CNode or the fee
rounding, or randomization for coin selection.

As a context is created per purpose, thus it gets rid of
cross-thread unprotected shared usage of a single set of globals, this
should also get rid of the potential race conditions.

- I'd say TxMempool::check is not called enough to warrant using a special
  fast random context, this is switched to GetRand() (open for
  discussion...)

- The use of `insecure_rand` in ConnectThroughProxy has been replaced by
  an atomic integer counter. The only goal here is to have a different
  credentials pair for each connection to go on a different Tor circuit,
  it does not need to be random nor unpredictable.

- To avoid having a FastRandomContext on every CNode, the context is
  passed into PushAddress as appropriate.

There remains an insecure_random for test usage in `test_random.h`.
2016-10-17 13:08:35 +02:00
Pieter Wuille 6aa28abf53 Use cmpctblock type 2 for segwit-enabled transfer
Contains version negotiation logic by Matt Corallo and bugfixes by
Suhas Daftuar.
2016-10-04 19:10:41 +02:00
Pavel Janík 4731cab8fb Do not shadow variables 2016-09-27 09:25:15 +02:00
MarcoFalke fa6dc9f0e5 Remove unused variables 2016-08-25 14:59:38 +02:00
Pieter Wuille f798b891bc
Merge #8346: Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs
a6cc299 Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs (Jorge Timón)
2016-08-01 00:09:14 +02:00
Jorge Timón a6cc299541 Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs 2016-07-29 00:48:20 +02:00
Pieter Wuille ab942c15bd Treat high-sigop transactions as larger rather than rejecting them 2016-07-19 12:31:49 +02:00
Suhas Daftuar 2c06bae39e Rename "block cost" to "block weight" 2016-07-18 13:28:26 -04:00
Pieter Wuille 2b1f6f9ccf BIP141: Other consensus critical limits, and BIP145
Includes changes by Suhas Daftuar, Luke-jr, and mruddy.
2016-06-22 15:43:00 +02:00
Matt Corallo 811902649d Provide a flat list of txid/terators to txn in CTxMemPool 2016-06-19 23:06:55 -07:00
Pieter Wuille 96806c39f4 Stop trimming when mapTx is empty 2016-06-19 01:34:57 -07:00
Pieter Wuille 288d85ddf2 Get rid of CTxMempool::lookup() entirely 2016-06-07 13:44:56 +02:00
Pieter Wuille 8d39d7a2cf Switch CTransaction storage in mempool to std::shared_ptr 2016-06-05 00:31:43 +02:00
Pieter Wuille a82f03393a
Merge #7997: replace mapNextTx with slimmer setSpends
9805f4a mapNextTx: use pointer as key, simplify value (Kaz Wesley)
2016-06-03 01:26:50 +02:00
Kaz Wesley 9805f4af7e mapNextTx: use pointer as key, simplify value
Saves about 10% of application memory usage once the mempool warms up. Since the
mempool is DynamicUsage-regulated, this will translate to a larger mempool in
the same amount of space.

Map value type: eliminate the vin index; no users of the map need to know which
input of the transaction is spending the prevout.

Map key type: replace the COutPoint with a pointer to a COutPoint. A COutPoint
is 36 bytes, but each COutPoint is accessible from the same map entry's value.
A trivial DereferencingComparator functor allows indirect map keys, but the
resulting syntax is misleading: `map.find(&outpoint)`. Implement an indirectmap
that acts as a wrapper to a map that uses a DereferencingComparator, supporting
a syntax that accurately reflect the container's semantics: inserts and
iterators use pointers since they store pointers and need them to remain
constant and dereferenceable, but lookup functions take const references.
2016-06-02 12:31:51 -07:00