Browse Source

Fixed functional test cases.

cn_mining
Jianping Wu 5 years ago
parent
commit
06770c9b2c
  1. 8
      src/chain.h
  2. 6
      src/chainparams.cpp
  3. 2
      src/rpc/mining.cpp
  4. 5
      src/wallet/wallet.cpp

8
src/chain.h

@ -213,6 +213,9 @@ public: @@ -213,6 +213,9 @@ public:
uint32_t nBits;
uint32_t nNonce;
//! Cryptonote header
CryptoNoteHeader cnHeader;
//! (memory only) Sequential id assigned to distinguish order in which blocks are received.
int32_t nSequenceId;
@ -240,6 +243,7 @@ public: @@ -240,6 +243,7 @@ public:
nTime = 0;
nBits = 0;
nNonce = 0;
cnHeader.SetNull();
}
CBlockIndex()
@ -256,6 +260,7 @@ public: @@ -256,6 +260,7 @@ public:
nTime = block.nTime;
nBits = block.nBits;
nNonce = block.nNonce;
cnHeader = block.cnHeader;
}
CDiskBlockPos GetBlockPos() const {
@ -286,6 +291,7 @@ public: @@ -286,6 +291,7 @@ public:
block.nTime = nTime;
block.nBits = nBits;
block.nNonce = nNonce;
block.cnHeader = cnHeader;
return block;
}
@ -410,6 +416,7 @@ public: @@ -410,6 +416,7 @@ public:
READWRITE(nTime);
READWRITE(nBits);
READWRITE(nNonce);
READWRITE(cnHeader);
}
uint256 GetBlockHash() const
@ -421,6 +428,7 @@ public: @@ -421,6 +428,7 @@ public:
block.nTime = nTime;
block.nBits = nBits;
block.nNonce = nNonce;
block.cnHeader = cnHeader;
return block.GetHash();
}

6
src/chainparams.cpp

@ -313,9 +313,9 @@ public: @@ -313,9 +313,9 @@ public:
nDefaultPort = 19444;
nPruneAfterHeight = 1000;
genesis = CreateGenesisBlock(1553147907, 6, 0x207fffff, 1, 50 * COIN);
genesis = CreateGenesisBlock(1296688602, 0, 0x207fffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x16c9c15caf4524e61004fcd4feb2217818b8884d4ad9b8769f5ea6c62c69097e"));
assert(consensus.hashGenesisBlock == uint256S("0x5b2e996d458adbf5c81b381f90ca167732bc9f4e9c1c4ec8485fa74efe793ed8"));
assert(genesis.hashMerkleRoot == uint256S("0x13ec98c3307b8e6b67b91c605c7347916a99f9dfde7b5d88365aaef322192314"));
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
@ -327,7 +327,7 @@ public: @@ -327,7 +327,7 @@ public:
checkpointData = {
{
{0, uint256S("530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9")},
{0, uint256S("5b2e996d458adbf5c81b381f90ca167732bc9f4e9c1c4ec8485fa74efe793ed8")},
}
};

2
src/rpc/mining.cpp

@ -134,7 +134,7 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen @@ -134,7 +134,7 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen
LOCK(cs_main);
IncrementExtraNonce(pblock, chainActive.Tip(), nExtraNonce);
}
pblock->cnHeader.prev_id = pblock->GetHash();
pblock->cnHeader.prev_id = pblock->GetOriginalBlockHash();
while (nMaxTries > 0 && pblock->nNonce < nInnerLoopCount && !CheckProofOfWork(pblock->GetPoWHash(), pblock->nBits, Params().GetConsensus())) {
++pblock->cnHeader.nonce;
--nMaxTries;

5
src/wallet/wallet.cpp

@ -2040,6 +2040,7 @@ CAmount CWallet::GetBalance() const @@ -2040,6 +2040,7 @@ CAmount CWallet::GetBalance() const
CAmount nTotal = 0;
{
LOCK2(cs_main, cs_wallet);
for (const auto& entry : mapWallet)
{
const CWalletTx* pcoin = &entry.second;
@ -3170,7 +3171,8 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon @@ -3170,7 +3171,8 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon
auto rejectReason = state.GetRejectReason();
LogPrintf("CommitTransaction(): Transaction cannot be broadcast immediately, %s\n", rejectReason);
// TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure.
if (rejectReason == "too-long-mempool-chain") {
bool isRegTest = Params().NetworkIDString() == CBaseChainParams::REGTEST;
if (!isRegTest && rejectReason == "too-long-mempool-chain") {
LogPrintf("Abandon the too-long-mempool-chain Tx: %s \n", wtx.GetHash().ToString().c_str());
AbandonTransaction(wtx.GetHash());
return false;
@ -4271,6 +4273,7 @@ int CMerkleTx::GetBlocksToMaturity() const @@ -4271,6 +4273,7 @@ int CMerkleTx::GetBlocksToMaturity() const
{
if (!IsCoinBase())
return 0;
return std::max(0, (COINBASE_MATURITY+1) - GetDepthInMainChain());
}

Loading…
Cancel
Save