aboutsummaryrefslogtreecommitdiff
path: root/src/coins.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add CChainState::ResizeCoinsCachesJames O'Beirne2020-07-011-0/+8
| | | | | | | | | | Also adds CCoinsViewCache::ReallocateCache() to attempt to free memory that the cacheCoins's allocator may be hanging onto when downsizing the cache. Adds `CChainState::m_coins{tip,db}_cache_size_bytes` data members so that we can reference cache size on a per-chainstate basis for flushing.
* Remove CCoinsViewCache::GetValueIn(...)practicalswift2020-05-031-12/+0
|
* [docs] use consistent naming for possible_overwriteJohn Newbery2020-04-211-3/+3
| | | | And other general comment improvements for adding coins.
* [docs] Improve commenting in coins.cpp|hJohn Newbery2020-04-211-19/+30
| | | | | Remove references to 'pruned' coins, which don't exist since the move to per-txout coins db.
* scripted-diff: Bump copyright of files changed in 2019MarcoFalke2019-12-301-1/+1
| | | | | | -BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
* move-onlyish: move CCoinsViewErrorCatcher out of init.cppJames O'Beirne2019-07-211-0/+17
| | | | | | | and into coins.cpp. This move is necessary so that we can later include a CCoinsViewErrorCatcher instance under CChainState. Co-authored-by: MarcoFalke <[email protected]>
* Extract CSipHasher to it's own file in crypto/ directory.Jim Posen2018-11-051-0/+1
| | | | This is a move-only commit with the exception of changes to includes.
* Drop unused GetType() from CSizeComputerBen Woosley2018-09-111-1/+1
|
* Update copyright headers to 2018DrahtBot2018-07-271-1/+1
|
* Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa2018-01-031-1/+1
|
* Remove includes in .cpp files for things the corresponding .h file already ↵practicalswift2017-11-161-3/+0
| | | | included
* scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider2017-11-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
* Small refactor of CCoinsViewCache::BatchWrite()Dan Raviv2017-09-161-46/+48
| | | | std::unordered_map::erase( const_iterator pos ) returns an iterator to the element following the removed one. Use that to optimize (probably minor-performance-wise, and definitely code-structure-wise) the implementation of CCoinsViewCache::BatchWrite().
* Use nullptr instead of zero (0) as the null pointer constantpracticalswift2017-08-161-1/+1
|
* Remove confusing MAX_BLOCK_BASE_SIZE.Gregory Maxwell2017-07-141-1/+2
| | | | | | | | | | | | | | | | | | Some people keep thinking that MAX_BLOCK_BASE_SIZE is a separate size limit from the weight limit when it fact it is superfluous, and used in early tests before the witness data has been validated or just to compute worst case sizes. The size checks that use it would not behave any differently consensus wise if they were eliminated completely. Its correct value is not independently settable but is a function of the weight limit and weight formula. This patch just eliminates it and uses the scale factor as required to compute the worse case constants. It also moves the weight factor out of primitives into consensus, which is a more logical place for it.
* Merge #10148: Use non-atomic flushing with block replayWladimir J. van der Laan2017-06-281-3/+6
|\ | | | | | | | | | | | | | | | | | | | | 176c021 [qa] Test non-atomic chainstate writes (Suhas Daftuar) d6af06d Dont create pcoinsTip until after ReplayBlocks. (Matt Corallo) eaca1b7 Random db flush crash simulator (Pieter Wuille) 0580ee0 Adapt memory usage estimation for flushing (Pieter Wuille) 013a56a Non-atomic flushing using the blockchain as replay journal (Pieter Wuille) b3a279c [MOVEONLY] Move LastCommonAncestor to chain (Pieter Wuille) Tree-SHA512: 47ccc62303f9075c44d2a914be75bd6969ff881a857a2ff1227f05ec7def6f4c71c46680c5a28cb150c814999526797dc05cf2701fde1369c06169f46eccddee
| * Non-atomic flushing using the blockchain as replay journalPieter Wuille2017-06-261-3/+6
| |
* | Simplify return values of GetCoin/HaveCoin(InCache)Pieter Wuille2017-06-261-2/+6
|/ | | | | | | | | | | This removes the possibility for GetCoin/HaveCoin/HaveCoinInCache to return true while the respective coin is spent. By doing it across all calls, some extra checks can be eliminated. coins_tests is modified to call HaveCoin sometimes before and sometimes after AccessCoin. A further change is needed because the semantics for GetCoin slightly changed, causing a pruned entry in the parent cache to not be pulled into the child in FetchCoin.
* Merge #10559: Change semantics of HaveCoinInCache to match HaveCoinWladimir J. van der Laan2017-06-261-1/+1
|\ | | | | | | | | | | 5257698 Change semantics of HaveCoinInCache to match HaveCoin (Alex Morcos) Tree-SHA512: 397e9ba28646b81fffa53e55064735d4d242aaffdf8484506825f785b0e414f334e4c5cd1e4e1dd9a4b6d1f6954c7ecad15429934a1c4e8d39f596cbd9f5dd80
| * Change semantics of HaveCoinInCache to match HaveCoinAlex Morcos2017-06-081-1/+1
| | | | | | | | | | | | | | | | | | | | Previously it was possible for HaveCoinInCache to return true for a spent coin. It is more clear to keep the semantics the same. HaveCoinInCache is used for two reasons: - tracking coins we may want to uncache, in which case it is unlikely there would be spent coins we could uncache (not dirty) - optimistically checking whether we have already included a tx in the blockchain, in which case a spent coin is not a reliable indicator that we have.
* | Merge #10537: Few Minor per-utxo assert-semantics re-adds and tweakPieter Wuille2017-06-201-2/+3
|\ \ | |/ |/| | | | | | | | | | | | | 9417d7a33 Be much more agressive in AccessCoin docs. (Matt Corallo) f58349ca8 Restore some assert semantics in sigop cost calculations (Matt Corallo) 3533fb4d3 Return a bool in SpendCoin to restore pre-per-utxo assert semantics (Matt Corallo) ec1271f2b Remove useless mapNextTx lookup in CTxMemPool::TrimToSize. (Matt Corallo) Tree-SHA512: 158a4bce063eac93e1d50709500a10a7cb1fb3271f10ed445d701852fce713e2bf0da3456088e530ab005f194ef4a2adf0c7cb23226b160cecb37a79561f29ca
| * Return a bool in SpendCoin to restore pre-per-utxo assert semanticsMatt Corallo2017-06-091-2/+3
| | | | | | | | | | Since its free to do so, assert that Spends succeeded when we expect them to.
* | [trivial] Fix typo: "occurrences" (misspelled as "occurrances")practicalswift2017-06-061-1/+1
|/ | | | | | | Typo introduced in 000391132608343c66488d62625c714814959bc9: $ git blame src/coins.cpp | grep occurrances 00039113 (2017-04-25 11:29:29 -0700 89) // deal with the pre-BIP30 occurrances of duplicate coinbase transactions.
* scripted-diff: various renames for per-utxo consistencyPieter Wuille2017-06-011-22/+22
| | | | | | | | | | | | | | | | | | | | | Thanks to John Newberry for pointing these out. -BEGIN VERIFY SCRIPT- sed -i 's/\<GetCoins\>/GetCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<HaveCoins\>/HaveCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<HaveCoinsInCache\>/HaveCoinInCache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<IsPruned\>/IsSpent/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<FetchCoins\>/FetchCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<CoinsEntry\>/CoinEntry/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<vHashTxnToUncache\>/coins_to_uncache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<vHashTxToUncache\>/coins_to_uncache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<fHadTxInCache\>/had_coin_in_cache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<coinbaseids\>/coinbase_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<disconnectedids\>/disconnected_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<duplicateids\>/duplicate_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h sed -i 's/\<oldcoins\>/old_coin/g' src/test/coins_tests.cpp sed -i 's/\<origcoins\>/orig_coin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h -END VERIFY SCRIPT-
* Rename CCoinsCacheEntry::coins to coinPieter Wuille2017-06-011-22/+22
|
* Merge CCoinsViewCache's GetOutputFor and AccessCoinPieter Wuille2017-06-011-8/+1
| | | | They're doing the same thing now.
* Remove unused CCoins methodsPieter Wuille2017-06-011-32/+0
|
* Switch CCoinsView and chainstate db from per-txid to per-txoutPieter Wuille2017-06-011-72/+40
| | | | | | | | | | | | | | This patch makes several related changes: * Changes the CCoinsView virtual methods (GetCoins, HaveCoins, ...) to be COutPoint/Coin-based rather than txid/CCoins-based. * Changes the chainstate db to a new incompatible format that is also COutPoint/Coin based. * Implements reconstruction code for hash_serialized_2. * Adapts the coins_tests unit tests (thanks to Russell Yanofsky). A side effect of the new CCoinsView model is that we can no longer use the (unreliable) test for transaction outputs in the UTXO set to determine whether we already have a particular transaction.
* Remove ModifyCoins/ModifyNewCoinsPieter Wuille2017-06-011-82/+1
|
* Introduce new per-txout CCoinsViewCache functionsPieter Wuille2017-06-011-1/+84
| | | | | | | | | | | | | | | | | | | | | | The new functions are: * CCoinsViewCache::AddCoin: Add a single COutPoint/Coin pair. * CCoinsViewCache::SpendCoin: Remove a single COutPoint. * AddCoins: utility function that invokes CCoinsViewCache::AddCoin for each output in a CTransaction. * AccessByTxid: utility function that searches for any output with a given txid. * CCoinsViewCache::AccessCoin: retrieve the Coin for a COutPoint. * CCoinsViewCache::HaveCoins: check whether a non-empty Coin exists for a given COutPoint. The AddCoin and SpendCoin methods will eventually replace ModifyCoins and ModifyNewCoins, AddCoins will replace CCoins::FromTx, and the new AccessCoins and HaveCoins functions will replace their per-txid counterparts. Note that AccessCoin for now returns a copy of the Coin object. In a later commit it will be change to returning a const reference (which keeps working in all call sites).
* Report on-disk size in gettxoutsetinfoPieter Wuille2017-05-261-0/+1
|
* [cleanup] Remove coin age priority completely.Alex Morcos2017-03-031-19/+0
| | | | Remove GetPriority and ComputePriority. Remove internal machinery for tracking priority in CTxMemPoolEntry.
* Check FRESH validity in CCoinsViewCache::BatchWriteRussell Yanofsky2017-01-041-0/+7
|
* Merge #9107: Safer modify new coinsPieter Wuille2017-01-041-6/+31
|\ | | | | | | b50cd7a Fix dangerous condition in ModifyNewCoins. (Alex Morcos)
| * Fix dangerous condition in ModifyNewCoins.Alex Morcos2017-01-041-6/+31
| | | | | | | | | | | | | | We were marking coins FRESH before being sure they were not overwriting dirty undo data. This condition was never reached in existing code because undo data was always flushed before UpdateCoins was called with new transactions, but could have been exposed in an otherwise safe refactor. Clarify in the comments the assumptions made in ModifyNewCoins. Add ability to undo transactions to UpdateCoins unit test. Thanks to Russ Yanofsky for suggestion on how to make logic clearer and fixing up the ccoins_modify_new test cases.
* | Increment MIT Licence copyright header year on files modified in 2016isle29832016-12-311-1/+1
|/ | | | | | Edited via: $ contrib/devtools/copyright_header.py update .
* Fix relaypriority calculation errormaiiz2016-09-201-1/+1
|
* Use C++11 thread-safe static initializersPieter Wuille2016-06-071-5/+1
|
* Use SipHash-2-4 for CCoinsCache indexPieter Wuille2016-05-171-1/+5
| | | | | This is ~1.7x slower than the Lookup3-of-Xor-with-salt construct we were using before, but it is a primitive designed for exactly this.
* txdb: Add Cursor() method to CCoinsView to iterate over UTXO setWladimir J. van der Laan2016-04-151-2/+6
| | | | | | | | | | Add a method Cursor() to CCoinsView that returns a cursor which can be used to iterate over the whole UTXO set. - rpc: Change gettxoutsetinfo to use new Cursor method - txdb: Remove GetStats method - Now that GetStats is implemented in terms of Cursor, remove it.
* Merge #7056: Save last db readWladimir J. van der Laan2016-01-221-2/+8
|\ | | | | | | 8504867 Save the last unnecessary database read (Alex Morcos)
| * Save the last unnecessary database readAlex Morcos2015-11-181-2/+8
| | | | | | | | It's possible coins with the same hash exist when you create a duplicate coinbase, so previously we were reading from the database to make sure we had the old coins cached so if we were to spend the new ones, the old ones would also be spent. This pull instead just marks the new coins as not fresh if they are from a coinbase, so if they are spent they will be written all the way down to the database anyway overwriting any duplicates.
* | Bump copyright headers to 2015MarcoFalke2015-12-131-1/+1
| |
* | Add CCoinsViewCache::HaveCoinsInCache to check if a tx is cachedMatt Corallo2015-12-011-0/+5
| |
* | Add method to remove a tx from CCoinsViewCache if it is unchangedMatt Corallo2015-12-011-0/+9
| |
* | Change GetPriority calculation.Alex Morcos2015-11-191-2/+4
|/ | | | Compute the value of inputs that already are in the chain at time of mempool entry and only increase priority due to aging for those inputs. This effectively changes the CTxMemPoolEntry's GetPriority calculation from an upper bound to a lower bound.
* Alter assumptions in CCoinsViewCache::BatchWriteAlex Morcos2015-11-181-7/+12
| | | | Previously it would break if you flushed a parent cache while there was a child cache referring to it. This change will allow the flushing of parent caches.
* ModifyNewCoins saves database lookupsAlex Morcos2015-11-021-0/+9
| | | | When processing a new transaction, in addition to spending the Coins of its txin's it creates a new Coins for its outputs. The existing ModifyCoins function will first make sure this Coins does not already exist. It can not exist due to BIP 30, but because of that the lookup can't be cached and always has to go to the database. Since we are creating the coins to match the new tx anyway, there is no point in checking if they exist first anyway. However this should not be used for coinbase tx's in order to preserve the historical behavior of overwriting the two existing duplicate tx pairs.
* Separate core memory usage computation in core_memusage.hPieter Wuille2015-07-201-7/+7
|
* Keep track of memory usage in CCoinsViewCachePieter Wuille2015-05-111-3/+21
|