Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
This commit is contained in:
parent
0d8118b1ed
commit
9b17b45da5
|
@ -13,7 +13,8 @@ RPC Changes
|
|||
- A new `end_of_service` object that contains both the block height for
|
||||
end-of-service and the estimated time that the end-of-service halt is
|
||||
expected to occur. Note that this height is just an approximation and
|
||||
should not be relied upon due to the variability in block times. The
|
||||
will change over time as the end-of-service block height approaches,
|
||||
due to the variability in block times. The
|
||||
`end_of_service` object is intended to replace the `deprecationheight`
|
||||
field; see the [Deprecations](#deprecations) section for additional detail.
|
||||
- This RPC method was previously only available for mainnet nodes; it is now
|
||||
|
|
|
@ -91,6 +91,9 @@ class WalletDeprecationTest(BitcoinTestFramework):
|
|||
default_enabled = dep_info['deprecated_features']
|
||||
default_disabled = dep_info['disabled_features']
|
||||
|
||||
for function in TESTABLE_FEATURES:
|
||||
assert(function in default_enabled or function in default_disabled)
|
||||
|
||||
# RPC methods that are deprecated but enabled by default should succeed
|
||||
for function in default_enabled:
|
||||
if function in TESTABLE_FEATURES:
|
||||
|
|
|
@ -28,6 +28,12 @@ bool fEnableWalletTxVJoinSplit = true;
|
|||
|
||||
static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION);
|
||||
|
||||
int64_t EstimatedNodeDeprecationTime(const CClock& clock, int nHeight) {
|
||||
auto blocksToDeprecation = DEPRECATION_HEIGHT - nHeight;
|
||||
|
||||
return clock.GetTime() + (blocksToDeprecation * Consensus::POST_BLOSSOM_POW_TARGET_SPACING);
|
||||
}
|
||||
|
||||
void EnforceNodeDeprecation(int nHeight, bool forceLogging, bool fThread) {
|
||||
|
||||
// Do not enforce deprecation in regtest or on testnet
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#define ZCASH_DEPRECATION_H
|
||||
|
||||
#include "consensus/params.h"
|
||||
#include "util/time.h"
|
||||
|
||||
// Deprecation policy:
|
||||
// Per https://zips.z.cash/zip-0200
|
||||
// Shut down nodes running this version of code, 16 weeks' worth of blocks after the estimated
|
||||
|
@ -62,6 +64,12 @@ extern bool fEnableAddrTypeField;
|
|||
extern bool fEnableWalletTxVJoinSplit;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the estimated time, in seconds since the epoch, at which deprecation
|
||||
* enforcement will take effect for this node.
|
||||
*/
|
||||
int64_t EstimatedNodeDeprecationTime(const CClock& clock, int nHeight);
|
||||
|
||||
/**
|
||||
* Checks whether the node is deprecated based on the current block height, and
|
||||
* shuts down the node with an error if so (and deprecation is not disabled for
|
||||
|
|
|
@ -470,9 +470,8 @@ UniValue getdeprecationinfo(const UniValue& params, bool fHelp)
|
|||
eos.pushKV("block_height", DEPRECATION_HEIGHT);
|
||||
{
|
||||
LOCK(cs_main);
|
||||
auto blocksToDeprecation = DEPRECATION_HEIGHT - chainActive.Height();
|
||||
|
||||
eos.pushKV("estimated_time", GetTime() + (blocksToDeprecation * EXPECTED_BLOCKS_PER_HOUR * 60 * 60));
|
||||
eos.pushKV("estimated_time", EstimatedNodeDeprecationTime(*GetNodeClock(), chainActive.Height()));
|
||||
}
|
||||
obj.pushKV("end_of_service", eos);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue