mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
RPC additions after headers-first
This commit is contained in:
parent
341735eb8f
commit
ad6e601712
@ -41,6 +41,7 @@ CCriticalSection cs_main;
|
|||||||
|
|
||||||
BlockMap mapBlockIndex;
|
BlockMap mapBlockIndex;
|
||||||
CChain chainActive;
|
CChain chainActive;
|
||||||
|
CBlockIndex *pindexBestHeader = NULL;
|
||||||
int64_t nTimeBestReceived = 0;
|
int64_t nTimeBestReceived = 0;
|
||||||
CWaitableCriticalSection csBestBlock;
|
CWaitableCriticalSection csBestBlock;
|
||||||
CConditionVariable cvBlockChange;
|
CConditionVariable cvBlockChange;
|
||||||
@ -51,6 +52,7 @@ bool fTxIndex = false;
|
|||||||
bool fIsBareMultisigStd = true;
|
bool fIsBareMultisigStd = true;
|
||||||
unsigned int nCoinCacheSize = 5000;
|
unsigned int nCoinCacheSize = 5000;
|
||||||
|
|
||||||
|
|
||||||
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying and mining) */
|
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying and mining) */
|
||||||
CFeeRate minRelayTxFee = CFeeRate(1000);
|
CFeeRate minRelayTxFee = CFeeRate(1000);
|
||||||
|
|
||||||
@ -98,8 +100,6 @@ namespace {
|
|||||||
// The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS or better that are at least
|
// The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS or better that are at least
|
||||||
// as good as our current tip. Entries may be failed, though.
|
// as good as our current tip. Entries may be failed, though.
|
||||||
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid;
|
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid;
|
||||||
// Best header we've seen so far (used for getheaders queries' starting points).
|
|
||||||
CBlockIndex *pindexBestHeader = NULL;
|
|
||||||
// Number of nodes with fSyncStarted.
|
// Number of nodes with fSyncStarted.
|
||||||
int nSyncStarted = 0;
|
int nSyncStarted = 0;
|
||||||
// All pairs A->B, where A (or one if its ancestors) misses transactions, but B has transactions.
|
// All pairs A->B, where A (or one if its ancestors) misses transactions, but B has transactions.
|
||||||
@ -440,6 +440,11 @@ bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) {
|
|||||||
return false;
|
return false;
|
||||||
stats.nMisbehavior = state->nMisbehavior;
|
stats.nMisbehavior = state->nMisbehavior;
|
||||||
stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1;
|
stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1;
|
||||||
|
stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1;
|
||||||
|
BOOST_FOREACH(const QueuedBlock& queue, state->vBlocksInFlight) {
|
||||||
|
if (queue.pindex)
|
||||||
|
stats.vHeightInFlight.push_back(queue.pindex->nHeight);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,9 @@ extern bool fIsBareMultisigStd;
|
|||||||
extern unsigned int nCoinCacheSize;
|
extern unsigned int nCoinCacheSize;
|
||||||
extern CFeeRate minRelayTxFee;
|
extern CFeeRate minRelayTxFee;
|
||||||
|
|
||||||
|
// Best header we've seen so far (used for getheaders queries' starting points).
|
||||||
|
extern CBlockIndex *pindexBestHeader;
|
||||||
|
|
||||||
// Minimum disk space required - used in CheckDiskSpace()
|
// Minimum disk space required - used in CheckDiskSpace()
|
||||||
static const uint64_t nMinDiskSpace = 52428800;
|
static const uint64_t nMinDiskSpace = 52428800;
|
||||||
|
|
||||||
@ -199,6 +202,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
struct CNodeStateStats {
|
struct CNodeStateStats {
|
||||||
int nMisbehavior;
|
int nMisbehavior;
|
||||||
int nSyncHeight;
|
int nSyncHeight;
|
||||||
|
int nCommonHeight;
|
||||||
|
std::vector<int> vHeightInFlight;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CDiskTxPos : public CDiskBlockPos
|
struct CDiskTxPos : public CDiskBlockPos
|
||||||
|
@ -445,6 +445,7 @@ Value getblockchaininfo(const Array& params, bool fHelp)
|
|||||||
"{\n"
|
"{\n"
|
||||||
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
|
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
|
||||||
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
|
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
|
||||||
|
" \"headers\": xxxxxx, (numeric) the current number of headers we have validated\n"
|
||||||
" \"bestblockhash\": \"...\", (string) the hash of the currently best block\n"
|
" \"bestblockhash\": \"...\", (string) the hash of the currently best block\n"
|
||||||
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
|
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
|
||||||
" \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
|
" \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
|
||||||
@ -458,6 +459,7 @@ Value getblockchaininfo(const Array& params, bool fHelp)
|
|||||||
Object obj;
|
Object obj;
|
||||||
obj.push_back(Pair("chain", Params().NetworkIDString()));
|
obj.push_back(Pair("chain", Params().NetworkIDString()));
|
||||||
obj.push_back(Pair("blocks", (int)chainActive.Height()));
|
obj.push_back(Pair("blocks", (int)chainActive.Height()));
|
||||||
|
obj.push_back(Pair("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1));
|
||||||
obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
|
obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
|
||||||
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
|
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
|
||||||
obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(chainActive.Tip())));
|
obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(chainActive.Tip())));
|
||||||
|
@ -97,7 +97,12 @@ Value getpeerinfo(const Array& params, bool fHelp)
|
|||||||
" \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n"
|
" \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n"
|
||||||
" \"startingheight\": n, (numeric) The starting height (block) of the peer\n"
|
" \"startingheight\": n, (numeric) The starting height (block) of the peer\n"
|
||||||
" \"banscore\": n, (numeric) The ban score\n"
|
" \"banscore\": n, (numeric) The ban score\n"
|
||||||
" \"syncnode\": true|false (boolean) if sync node\n"
|
" \"synced_headers\": n, (numeric) The last header we have in common with this peer\n"
|
||||||
|
" \"synced_blocks\": n, (numeric) The last block we have in common with this peer\n"
|
||||||
|
" \"inflight\": [\n"
|
||||||
|
" n, (numeric) The heights of blocks we're currently asking from this peer\n"
|
||||||
|
" ...\n"
|
||||||
|
" ]\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" ,...\n"
|
" ,...\n"
|
||||||
"]\n"
|
"]\n"
|
||||||
@ -137,7 +142,13 @@ Value getpeerinfo(const Array& params, bool fHelp)
|
|||||||
obj.push_back(Pair("startingheight", stats.nStartingHeight));
|
obj.push_back(Pair("startingheight", stats.nStartingHeight));
|
||||||
if (fStateStats) {
|
if (fStateStats) {
|
||||||
obj.push_back(Pair("banscore", statestats.nMisbehavior));
|
obj.push_back(Pair("banscore", statestats.nMisbehavior));
|
||||||
obj.push_back(Pair("syncheight", statestats.nSyncHeight));
|
obj.push_back(Pair("synced_headers", statestats.nSyncHeight));
|
||||||
|
obj.push_back(Pair("synced_blocks", statestats.nCommonHeight));
|
||||||
|
Array heights;
|
||||||
|
BOOST_FOREACH(int height, statestats.vHeightInFlight) {
|
||||||
|
heights.push_back(height);
|
||||||
|
}
|
||||||
|
obj.push_back(Pair("inflight", heights));
|
||||||
}
|
}
|
||||||
obj.push_back(Pair("whitelisted", stats.fWhitelisted));
|
obj.push_back(Pair("whitelisted", stats.fWhitelisted));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user