Make it compile and apply some fixes

This commit is contained in:
lateminer
2018-10-14 22:49:30 +03:00
parent af1585d232
commit eea97b0e37
6 changed files with 34 additions and 24 deletions

View File

@@ -255,6 +255,23 @@ CTxDestination DecodeDestination(const std::string &str, const CChainParams &par
}
} // namespace
namespace
{
class CBitcoinAddressVisitor : public boost::static_visitor<bool>
{
private:
CBitcoinAddress* addr;
public:
CBitcoinAddressVisitor(CBitcoinAddress* addrIn) : addr(addrIn) {}
bool operator()(const CKeyID& id) const { return addr->Set(id); }
bool operator()(const CScriptID& id) const { return addr->Set(id); }
bool operator()(const CNoDestination& no) const { return false; }
};
} // anon namespace
bool CBitcoinAddress::Set(const CKeyID& id)
{
SetData(Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS), &id, 20);

View File

@@ -3404,7 +3404,7 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const
REJECT_OBSOLETE, "bad-version");
// Check proof of work matches claimed amount
if (fCheckPOW && !CheckProofOfWork(block.GetPoWHash(), block.nBits, consensusParams))
if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, consensusParams))
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),
REJECT_INVALID, "high-hash");
return true;

View File

@@ -71,8 +71,7 @@ int64_t UpdateTime(CBlock* pblock, const Consensus::Params& consensusParams, con
// Updating time can change work required on testnet:
if (consensusParams.fPowAllowMinDifficultyBlocks)
pblock->nBits = GetNextTargetRequired(pindexPrev, pblock, consensusParams, pblock->IsProofOfStake());
pblock->nBits = GetNextTargetRequired(pindexPrev, pblock, consensusParams, pblock->IsProofOfStake());
return nNewTime - nOldTime;
}
@@ -434,7 +433,7 @@ void static BitcoinMiner(const CChainParams& chainparams)
//
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
CBlockIndex* pindexPrev = chainActive.Tip();
int64_t *nFees;
int64_t* nFees = 0;
std::unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlock(chainparams, coinbaseScript->reserveScript, nFees, false));
if (!pblocktemplate.get())
{

View File

@@ -30,20 +30,22 @@ static arith_uint256 GetTargetLimit(int64_t nTime, const Consensus::Params& para
unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params, bool fProofOfStake)
{
unsigned int nTargetLimit = UintToArith256(params.powLimit).GetCompact();
// Genesis block
if (pindexLast == NULL)
return nTargetLimit;
// Genesis block
if (pindexLast == NULL)
return UintToArith256(params.powLimit).GetCompact();
else {
unsigned int nTargetLimit = GetTargetLimit(pindexLast->GetBlockTime(), params, fProofOfStake).GetCompact();
const CBlockIndex* pindexPrev = GetLastBlockIndex(pindexLast, fProofOfStake);
if (pindexPrev->pprev == NULL)
return nTargetLimit; // first block
const CBlockIndex* pindexPrevPrev = GetLastBlockIndex(pindexPrev->pprev, fProofOfStake);
if (pindexPrevPrev->pprev == NULL)
return nTargetLimit; // second block
return CalculateNextTargetRequired(pindexPrev, pindexPrevPrev->GetBlockTime(), params, fProofOfStake);
return CalculateNextTargetRequired(pindexPrev, pindexPrevPrev->GetBlockTime(), params, fProofOfStake);
}
}
unsigned int CalculateNextTargetRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params, bool fProofOfStake)
@@ -56,8 +58,8 @@ unsigned int CalculateNextTargetRequired(const CBlockIndex* pindexLast, int64_t
return pindexLast->nBits;
}
int64_t nActualSpacing = pindexLast->GetBlockTime() - nFirstBlockTime;
int64_t nTargetSpacing = params.IsProtocolV2(pindexLast->GetBlockTime()) ? params.nTargetSpacing : params.nTargetSpacingV1;
int64_t nActualSpacing = pindexLast->GetBlockTime() - nFirstBlockTime;
// Limit adjustment step
if (pindexLast->GetBlockTime() > params.nProtocolV1RetargetingFixedTime && nActualSpacing < 0)

View File

@@ -13,9 +13,9 @@
uint256 CBlockHeader::GetHash() const
{
if (nVersion > 6)
return SerializeHash(*this);
return GetPoWHash();
if (nVersion > 6)
return SerializeHash(*this);
return GetPoWHash();
}
uint256 CBlockHeader::GetPoWHash() const
@@ -34,8 +34,8 @@ std::string CBlock::ToString() const
hashPrevBlock.ToString(),
hashMerkleRoot.ToString(),
nTime, nBits, nNonce,
vtx.size(),
HexStr(vchBlockSig.begin(), vchBlockSig.end()));
vtx.size(),
HexStr(vchBlockSig.begin(), vchBlockSig.end()));
for (unsigned int i = 0; i < vtx.size(); i++)
{
s << " " << vtx[i].ToString() << "\n";

View File

@@ -960,14 +960,6 @@ void BitcoinGUI::showEvent(QShowEvent *event)
optionsAction->setEnabled(true);
}
void BitcoinGUI::showEvent(QShowEvent *event)
{
// enable the debug window when the main window shows up
openRPCConsoleAction->setEnabled(true);
aboutAction->setEnabled(true);
optionsAction->setEnabled(true);
}
#ifdef ENABLE_WALLET
void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label)
{