-
Notifications
You must be signed in to change notification settings - Fork 35.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CBufferedFile and use it for -loadblock and bootstrap.dat #1962
Conversation
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/f7bb8d71edbe2168622040ed8f13867e44f57cb5 for binaries and test log. |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/0e53edbd61b9020b338a9fd7cae24fb5ed575d02 for binaries and test log. |
ACK
|
bitcoin#1962 changes the minimum required confirmations for InstantSend to 2 when running in testnet. This resulted in the quorum rank calculation to pick blocks which are higher then the current chain tip. This commit fixes this by calculating the added height based on nInstantSendConfirmationsRequired. This results in the value 4 for mainnet, so no incompatibility is introduced. On testnet and regtest, this results in 0.
056cf79 [Wallet] Remove spent coins from the availableCoins cache for staking (random-zebra) f938a0b [Wallet] Check if coin is spent before trying to stake with it (random-zebra) 2b1a57a [Miner] Check for stakeable coins at every block (random-zebra) Pull request description: Currently, during the staking thread, the list of available coins is updated every 5 minutes. This can lead to two problems: - If a coin is not included due to low confirmations number, when it matures, it cannot be staked immediately: it gets included only after the full 5 minutes. - If a coin is spent, it is not removed immediately from the list. So, if a valid kernel is found with said coin, the following two things happen. First, the newly created block fails `TestBlockValidity` (as it contains essentially a double spend) and gets discarded by the staker, who also clears his mempool (thus removing the transaction that was spending the coin). Then, after few seconds, the staker tries again with the same coin, finding again a valid kernel with it, but this time creating a (valid) empty block. The wallet transaction, originally spending the stake input, and later removed from the memory pool, is now marked conflicted. For now, let's address the issue by: - reloading the list of available coins whenever the tip hash changes (so, at least, at every block). - checking for in-wallet spent-status before staking (as the list of coins is updated only when a new block arrives, a certain coin could have been spent in the mempool afterwards). Closes bitcoin#1923 A better approach (future work), would be to implement an interface in the miner, subscribing to the wallet signals and updating the stakeable coins cache only when a coin is added, or is spent (or matures). ACKs for top commit: furszy: nice fix man, ACK 056cf79. Fuzzbawls: utACK 056cf79 Tree-SHA512: 83e481d5801ef3c5b3cb9a195770c333a2236ec6eae89474020c6768c53b48d2132d8a641f299259c8f8e4ec346fbcad9f5646d952a1f19784aa0991db50fa97
The first commit adds CBufferedFile, which works like CAutoFile, but buffers the data in memory, so it is rewindable, and supports fast scanning inside the buffer.
The second commits switches LoadExternalBlocksFromFile to use CBufferedFile, simplifying it, and removing all fseek()'s.