Skip to content
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

Block height is changed to 32 bit from 64 bit #286

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CChainParams

/** Default value for -checkmempool and -checkblockindex argument */
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
uint32_t PruneAfterHeight() const { return nPruneAfterHeight; }
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
/** Return true if the fallback fee is by default enabled for this network */
Expand All @@ -79,7 +79,7 @@ class CChainParams
Consensus::Params consensus;
int rpcPort;
int nDefaultPort;
uint64_t nPruneAfterHeight;
uint32_t nPruneAfterHeight;
bool fDefaultConsistencyChecks;
bool fMineBlocksOnDemand;
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ static UniValue getblockhash(const JSONRPCRequest& request)

LOCK(cs_main);

int nHeight = request.params[0].get_int();
uint32_t nHeight = request.params[0].get_int();
if (nHeight < 0 || nHeight > chainActive.Height())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");

Expand Down Expand Up @@ -906,7 +906,7 @@ static UniValue pruneblockchain(const JSONRPCRequest& request)
}

PruneBlockFilesManual(height);
return uint64_t(height);
return UniValue(height);
}

static UniValue gettxoutsetinfo(const JSONRPCRequest& request)
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ unsigned int ParseConfirmTarget(const UniValue& value)

UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, bool keepScript, const CKey& privKey)
{
int nHeightEnd = 0;
int nHeight = 0;
uint32_t nHeightEnd = 0;
uint32_t nHeight = 0;

{ // Don't keep cs_main locked
LOCK(cs_main);
Expand Down Expand Up @@ -587,7 +587,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
result.pushKV("sizelimit", (int64_t)GetCurrentMaxBlockSize());
result.pushKV("curtime", pblock->GetBlockTime());
result.pushKV("proof", HexStr(pblock->proof));
result.pushKV("height", (int64_t)(pindexPrev->nHeight+1));
result.pushKV("height", (pindexPrev->nHeight+1));

if (!pblocktemplate->vchCoinbaseCommitment.empty() && fSupportsSegwit) {
result.pushKV("default_witness_commitment", HexStr(pblocktemplate->vchCoinbaseCommitment.begin(), pblocktemplate->vchCoinbaseCommitment.end()));
Expand Down
2 changes: 1 addition & 1 deletion src/test/pmt_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(pmt_test1)
std::vector<uint256> vTxid(nTx, uint256());
for (unsigned int j=0; j<nTx; j++)
vTxid[j] = block.vtx[j]->GetHashMalFix();
int nHeight = 1, nTx_ = nTx;
uint32_t nHeight = 1, nTx_ = nTx;
while (nTx_ > 1) {
nTx_ = (nTx_+1)/2;
nHeight++;
Expand Down
2 changes: 1 addition & 1 deletion src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
uint64_t innerUsage = 0;

CCoinsViewCache mempoolDuplicate(const_cast<CCoinsViewCache*>(pcoins));
const int64_t spendheight = GetSpendHeight(mempoolDuplicate);
const int32_t spendheight = GetSpendHeight(mempoolDuplicate);

std::list<const CTxMemPoolEntry*> waitingOnDependants;
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
Expand Down
9 changes: 8 additions & 1 deletion src/univalue/include/univalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class UniValue {
UniValue(bool val_) {
setBool(val_);
}
UniValue(uint32_t val_) {
setInt((uint64_t)val_);
}
UniValue(int val_) {
setInt(val_);
}
Expand Down Expand Up @@ -133,7 +136,11 @@ class UniValue {
UniValue tmpVal((bool)val_);
return pushKV(key, tmpVal);
}
bool pushKV(const std::string& key, int val_) {
bool pushKV(const std::string& key, uint32_t val_) {
UniValue tmpVal((uint64_t)val_);
return pushKV(key, tmpVal);
}
bool pushKV(const std::string& key, int32_t val_) {
UniValue tmpVal((int64_t)val_);
return pushKV(key, tmpVal);
}
Expand Down
10 changes: 5 additions & 5 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ enum class FlushStateMode {
// See definition for documentation
static bool FlushStateToDisk(CValidationState &state, FlushStateMode mode, int nManualPruneHeight=0);
static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight);
static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight);
static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint32_t nPruneAfterHeight);
bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData& txdata, TxColoredCoinBalancesMap& inColoredCoinBalances, std::vector<CScriptCheck> *pvChecks = nullptr);
static FILE* OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly = false);

Expand Down Expand Up @@ -1232,7 +1232,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, int nHeight)
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
{
CDiskBlockPos blockPos;
uint64_t height = 0;
uint32_t height = 0;
{
LOCK(cs_main);
blockPos = pindex->GetBlockPos();
Expand Down Expand Up @@ -3542,13 +3542,13 @@ void PruneBlockFilesManual(int nManualPruneHeight)
*
* @param[out] setFilesToPrune The set of file indices that can be unlinked will be returned
*/
static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight)
static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint32_t nPruneAfterHeight)
{
LOCK2(cs_main, cs_LastBlockFile);
if (chainActive.Tip() == nullptr || nPruneTarget == 0) {
return;
}
if ((uint64_t)chainActive.Tip()->nHeight <= nPruneAfterHeight) {
if (chainActive.Tip()->nHeight <= nPruneAfterHeight) {
return;
}

Expand Down Expand Up @@ -4653,7 +4653,7 @@ bool isBlockHeightInCoinbase(const CBlock& block)
if(pindex->nHeight == 0)
return true;

uint64_t blockHeight = block.GetHeight();
uint32_t blockHeight = block.GetHeight();

if(block.GetHash() == pindex->GetBlockHash() && blockHeight != (uint32_t)pindex->nHeight)
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/xfieldhistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void CXFieldHistory::ToUniValue(TAPYRUS_XFIELDTYPES type, UniValue* xFieldChange
{
UniValue xFieldChangeObj(UniValue::VOBJ);
std::string value = XFieldDataToString(xFieldChange.xfieldValue);
xFieldChangeObj.pushKV(value, (uint64_t)xFieldChange.height);
xFieldChangeObj.pushKV(value, xFieldChange.height);
xFieldChangeUnival->push_back(xFieldChangeObj);
}
}
Expand Down