mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
Merge bitcoin/bitcoin#25667: assumeutxo: snapshot initialization
bf95976061doc: add note about snapshot chainstate init (James O'Beirne)e4d7995286test: add testcases for snapshot initialization (James O'Beirne)cced4e7336test: move-only-ish: factor out LoadVerifyActivateChainstate() (James O'Beirne)51fc9241c0test: allow on-disk coins and block tree dbs in tests (James O'Beirne)3c361391b8test: add reset_chainstate parameter for snapshot unittests (James O'Beirne)00b357c215validation: add ResetChainstates() (James O'Beirne)3a29dfbfb2move-only: test: make snapshot chainstate setup reusable (James O'Beirne)8153bd9247blockmanager: avoid undefined behavior during FlushBlockFile (James O'Beirne)ad67ff377cvalidation: remove snapshot datadirs upon validation failure (James O'Beirne)34d1590331add utilities for deleting on-disk leveldb data (James O'Beirne)252abd1e8binit: add utxo snapshot detection (James O'Beirne)f9f1735f13validation: rename snapshot chainstate dir (James O'Beirne)d14bebf100db: add StoragePath to CDBWrapper/CCoinsViewDB (James O'Beirne) Pull request description: This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11) (parent PR: https://github.com/bitcoin/bitcoin/pull/15606) --- Half of the replacement for #24232. The original PR grew larger than expected throughout the review process. This change adds the ability to initialize a snapshot-based chainstate during init if one is detected on disk. This is of course unused as of now (aside from in unittests) given that we haven't yet enabled actually loading snapshots. Don't be scared! There are some big move-only commits in here. Accompanying changes include: - moving the snapshot coinsdb directory from being called `chainstate_[base blockhash]` to `chainstate_snapshot`, since we only support one snapshot in use at a time. This simplifies some logic, but it necessitates writing that base blockhash out to a file within the coinsdb dir. See [discussion here](https://github.com/bitcoin/bitcoin/pull/24232#discussion_r832762880). - adding a simple fix in `FlushBlockFile()` that avoids a crash when attemping to flush to disk before `LoadBlockIndexDB()` is called, which happens when calling `MaybeRebalanceCaches()` during multiple chainstate init. - improving the unittest to allow testing with on-disk chainstates - necessary to test a simulated restart and re-initialization. ACKs for top commit: naumenkogs: utACKbf95976061ariard: Code Review ACKbf9597606ryanofsky: Code review ACKbf95976061. Changes since last review: rebasing, switching from CAutoFile to AutoFile, adding comments, switching from BOOST_CHECK to Assert in test util, using chainman.GetMutex() in tests, destroying one ChainstateManager before creating a new one in tests fjahr: utACKbf95976061aureleoules: ACKbf95976061Tree-SHA512: 15ae75caf19f8d12a12d2647c52897904d27b265a7af6b4ae7b858592eeadb8f9da6c2394b6baebec90adc28742c053e3eb506119577dae7c1e722ebb3b7bcc0
This commit is contained in:
@@ -487,12 +487,14 @@ public:
|
||||
AutoFile(const AutoFile&) = delete;
|
||||
AutoFile& operator=(const AutoFile&) = delete;
|
||||
|
||||
void fclose()
|
||||
int fclose()
|
||||
{
|
||||
int retval{0};
|
||||
if (file) {
|
||||
::fclose(file);
|
||||
retval = ::fclose(file);
|
||||
file = nullptr;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/** Get wrapped FILE* with transfer of ownership.
|
||||
|
||||
Reference in New Issue
Block a user