Pharao Release
Version 4.0.0.4 - refactored code - migrated vom Qt4 to Qt5 - added secure messaging
This commit is contained in:
+58
-5
@@ -4,12 +4,13 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "main.h"
|
||||
#include "bitcoinrpc.h"
|
||||
#include "trianglesrpc.h"
|
||||
|
||||
using namespace json_spirit;
|
||||
using namespace std;
|
||||
|
||||
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, json_spirit::Object& entry);
|
||||
extern enum Checkpoints::CPMode CheckpointsMode;
|
||||
|
||||
double GetDifficulty(const CBlockIndex* blockindex)
|
||||
{
|
||||
@@ -42,6 +43,33 @@ double GetDifficulty(const CBlockIndex* blockindex)
|
||||
return dDiff;
|
||||
}
|
||||
|
||||
double GetPoWMHashPS()
|
||||
{
|
||||
if (pindexBest->nHeight >= CUTOFF_POW_BLOCK)
|
||||
return 0;
|
||||
|
||||
int nPoWInterval = 72;
|
||||
int64_t nTargetSpacingWorkMin = 30, nTargetSpacingWork = 30;
|
||||
|
||||
CBlockIndex* pindex = pindexGenesisBlock;
|
||||
CBlockIndex* pindexPrevWork = pindexGenesisBlock;
|
||||
|
||||
while (pindex)
|
||||
{
|
||||
if (pindex->IsProofOfWork())
|
||||
{
|
||||
int64_t nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime();
|
||||
nTargetSpacingWork = ((nPoWInterval - 1) * nTargetSpacingWork + nActualSpacingWork + nActualSpacingWork) / (nPoWInterval + 1);
|
||||
nTargetSpacingWork = max(nTargetSpacingWork, nTargetSpacingWorkMin);
|
||||
pindexPrevWork = pindex;
|
||||
}
|
||||
|
||||
pindex = pindex->pnext;
|
||||
}
|
||||
|
||||
return GetDifficulty() * 4294.967296 / nTargetSpacingWork;
|
||||
}
|
||||
|
||||
double GetPoSKernelPS()
|
||||
{
|
||||
int nPoSInterval = 72;
|
||||
@@ -83,7 +111,8 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
|
||||
result.push_back(Pair("nonce", (boost::uint64_t)block.nNonce));
|
||||
result.push_back(Pair("bits", HexBits(block.nBits)));
|
||||
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
|
||||
|
||||
result.push_back(Pair("blocktrust", leftTrim(blockindex->GetBlockTrust().GetHex(), '0')));
|
||||
result.push_back(Pair("chaintrust", leftTrim(blockindex->nChainTrust.GetHex(), '0')));
|
||||
if (blockindex->pprev)
|
||||
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
|
||||
if (blockindex->pnext)
|
||||
@@ -92,7 +121,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
|
||||
result.push_back(Pair("flags", strprintf("%s%s", blockindex->IsProofOfStake()? "proof-of-stake" : "proof-of-work", blockindex->GeneratedStakeModifier()? " stake-modifier": "")));
|
||||
result.push_back(Pair("proofhash", blockindex->IsProofOfStake()? blockindex->hashProofOfStake.GetHex() : blockindex->GetBlockHash().GetHex()));
|
||||
result.push_back(Pair("entropybit", (int)blockindex->GetStakeEntropyBit()));
|
||||
result.push_back(Pair("modifier", strprintf("%016"PRI64x, blockindex->nStakeModifier)));
|
||||
result.push_back(Pair("modifier", strprintf("%016"PRIx64, blockindex->nStakeModifier)));
|
||||
result.push_back(Pair("modifierchecksum", strprintf("%08x", blockindex->nStakeModifierChecksum)));
|
||||
Array txinfo;
|
||||
BOOST_FOREACH (const CTransaction& tx, block.vtx)
|
||||
@@ -111,11 +140,22 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
|
||||
}
|
||||
|
||||
result.push_back(Pair("tx", txinfo));
|
||||
result.push_back(Pair("signature", HexStr(block.vchBlockSig.begin(), block.vchBlockSig.end())));
|
||||
|
||||
if (block.IsProofOfStake())
|
||||
result.push_back(Pair("signature", HexStr(block.vchBlockSig.begin(), block.vchBlockSig.end())));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Value getbestblockhash(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 0)
|
||||
throw runtime_error(
|
||||
"getbestblockhash\n"
|
||||
"Returns the hash of the best block in the longest block chain.");
|
||||
|
||||
return hashBestChain.GetHex();
|
||||
}
|
||||
|
||||
Value getblockcount(const Array& params, bool fHelp)
|
||||
{
|
||||
@@ -246,11 +286,24 @@ Value getcheckpoint(const Array& params, bool fHelp)
|
||||
CBlockIndex* pindexCheckpoint;
|
||||
|
||||
result.push_back(Pair("synccheckpoint", Checkpoints::hashSyncCheckpoint.ToString().c_str()));
|
||||
pindexCheckpoint = mapBlockIndex[Checkpoints::hashSyncCheckpoint];
|
||||
pindexCheckpoint = mapBlockIndex[Checkpoints::hashSyncCheckpoint];
|
||||
result.push_back(Pair("height", pindexCheckpoint->nHeight));
|
||||
result.push_back(Pair("timestamp", DateTimeStrFormat(pindexCheckpoint->GetBlockTime()).c_str()));
|
||||
|
||||
// Check that the block satisfies synchronized checkpoint
|
||||
if (CheckpointsMode == Checkpoints::STRICT)
|
||||
result.push_back(Pair("policy", "strict"));
|
||||
|
||||
if (CheckpointsMode == Checkpoints::ADVISORY)
|
||||
result.push_back(Pair("policy", "advisory"));
|
||||
|
||||
if (CheckpointsMode == Checkpoints::PERMISSIVE)
|
||||
result.push_back(Pair("policy", "permissive"));
|
||||
|
||||
if (mapArgs.count("-checkpointkey"))
|
||||
result.push_back(Pair("checkpointmaster", true));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user