Skip to content

Commit

Permalink
refinements to the block explorer and a new YACprice
Browse files Browse the repository at this point in the history
slightly changed block explorer code.  But a new YAC price display,
triggered by (more or less) each new block.  This and the explorer are
not meant to be the final say on the matter. They are just to show what
can be done.  Change to your pleasure.
  • Loading branch information
ya-old-c-coder committed Jul 19, 2015
1 parent 7142482 commit 8aefde6
Show file tree
Hide file tree
Showing 19 changed files with 1,102 additions and 246 deletions.
4 changes: 2 additions & 2 deletions src/allocators.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class MemoryPageLocker
bool Lock(const void *addr, size_t len)
{
#ifdef WIN32
return VirtualLock(const_cast<void*>(addr), len);
return (bool)VirtualLock(const_cast<void*>(addr), len);
#else
return mlock(addr, len) == 0;
#endif
Expand All @@ -176,7 +176,7 @@ class MemoryPageLocker
bool Unlock(const void *addr, size_t len)
{
#ifdef WIN32
return VirtualUnlock(const_cast<void*>(addr), len);
return (bool)VirtualUnlock(const_cast<void*>(addr), len);
#else
return munlock(addr, len) == 0;
#endif
Expand Down
5 changes: 3 additions & 2 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ int64 AmountFromValue(const Value& value)

Value ValueFromAmount(int64 amount)
{
return (double)amount / (double)COIN;
return (double)amount / (double)COIN;
}

std::string HexBits(unsigned int nBits)
Expand Down Expand Up @@ -221,6 +221,7 @@ static const CRPCCommand vRPCCommands[] =
{ "getblockcount", &getblockcount, true, false },
#ifdef WIN32
{ "getblockcountt", &getcurrentblockandtime, true, false },
{ "getyacprice", &getYACprice, true, false },
#endif
{ "getconnectioncount", &getconnectioncount, true, false },
{ "getpeerinfo", &getpeerinfo, true, false },
Expand Down Expand Up @@ -285,7 +286,7 @@ static const CRPCCommand vRPCCommands[] =
{ "repairwallet", &repairwallet, false, true},
{ "resendtx", &resendtx, false, true},
{ "makekeypair", &makekeypair, false, true},
{ "sendalert", &sendalert, false, false},
{ "sendalert", &sendalert, false, false}
};

CRPCTable::CRPCTable()
Expand Down
7 changes: 2 additions & 5 deletions src/bitcoinrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
#include <list>
#include <map>

#ifdef WIN32
#ifdef QT_GUI
#include "time.h"
#endif
#endif
class CBlockIndex;

#include "json/json_spirit_reader_template.h"
Expand Down Expand Up @@ -200,6 +195,8 @@ extern json_spirit::Value sendrawtransaction(const json_spirit::Array& params, b

#ifdef WIN32
extern json_spirit::Value getcurrentblockandtime(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getYACprice(const json_spirit::Array& params, bool fHelp);
extern double doGetYACprice(void);
#endif
extern json_spirit::Value getblockcount(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp
extern json_spirit::Value getdifficulty(const json_spirit::Array& params, bool fHelp);
Expand Down
109 changes: 71 additions & 38 deletions src/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
using namespace std;
using namespace boost;


unsigned int nWalletDBUpdated;



//
// CDB
//
Expand Down Expand Up @@ -765,28 +762,43 @@ bool CTxDB::LoadBlockIndex()
vSortedByHeight.reserve(mapBlockIndex.size());
#ifdef WIN32
if (fPrintToConsole)
(void)printf( "Sorting by height..." );
(void)printf( "Sorting by height...\n" );
#ifdef QT_GUI
uiInterface.InitMessage(
_("Sorting by height...")
);
#endif
int
nCount = 0;
#endif
BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex)
{
CBlockIndex* pindex = item.second;
vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex));
#ifdef WIN32
++nCount;
if( 0 == (nCount % 10000) )
{
#ifdef QT_GUI
uiInterface.InitMessage( strprintf( _("%7d"), nCount ) );
#else
#ifdef _MSC_VER
if (fPrintToConsole)
printf( "%7d\r", nCount );
#endif
#endif
}
#endif
}
sort(vSortedByHeight.begin(), vSortedByHeight.end());
#ifdef WIN32
if (fPrintToConsole)
(void)printf( "done\nChecking stake checksums..." );
(void)printf( "\ndone\nChecking stake checksums...\n" );
#ifdef QT_GUI
uiInterface.InitMessage( _("done") );
uiInterface.InitMessage( _("Checking stake checksums...") );
#endif
int
nCount = 0;
nCount = 0;
#endif
BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
{
Expand All @@ -797,16 +809,23 @@ bool CTxDB::LoadBlockIndex()
if (!CheckStakeModifierCheckpoints(pindex->nHeight, pindex->nStakeModifierChecksum))
return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016"PRI64x, pindex->nHeight, pindex->nStakeModifier);
#ifdef WIN32
#ifdef QT_GUI
++nCount;
if( 0 == (nCount % 10000) )
{
#ifdef QT_GUI
uiInterface.InitMessage( strprintf( _("%7d"), nCount ) );
#else
#ifdef _MSC_VER
if (fPrintToConsole)
printf( "%7d\r", nCount );
#endif
#endif
}
#endif
}
#ifdef WIN32
if (fPrintToConsole)
(void)printf( "...done\n"
(void)printf( "\ndone\n"
"Read best chain\n"
);
#ifdef QT_GUI
Expand Down Expand Up @@ -854,7 +873,7 @@ bool CTxDB::LoadBlockIndex()
nMINUTESperBLOCK = 1, // or whatever you want to do in this *coin
nMINUTESperHOUR = 60,
nBLOCKSperHOUR = nMINUTESperHOUR / nMINUTESperBLOCK,
nHOURStoCHECK = 12, // this could be a variable
nHOURStoCHECK = 1, //12, // this could be a variable
nBLOCKSinLAST12HOURS = nBLOCKSperHOUR * nHOURStoCHECK;

nCheckDepth = nBLOCKSinLAST12HOURS;
Expand Down Expand Up @@ -886,8 +905,11 @@ bool CTxDB::LoadBlockIndex()
);
#endif
#ifdef QT_GUI
sX = strprintf( _("Verifying the last %4d blocks"), nCheckDepth - nCount );
uiInterface.InitMessage( sX.c_str() );
if( !( (nCheckDepth - nCount) % 2 ) )
{
sX = strprintf( _("Verifying the last %4d blocks"), nCheckDepth - nCount );
uiInterface.InitMessage( sX.c_str() );
}
#endif
#endif
if (!block.ReadFromDisk(pindex))
Expand Down Expand Up @@ -1169,6 +1191,16 @@ bool CTxDB::LoadBlockIndexGuts()
int
nMaxHeightGuess = 0,
nCount = 0;
const int
#ifdef _DEBUG
nRefresh = 2000;
#else
#ifdef QT_GUI
nRefresh = 4000;
#else
nRefresh = 5000; //10000;
#endif
#endif
#endif
// Load mapBlockIndex
unsigned int fFlags = DB_SET_RANGE;
Expand Down Expand Up @@ -1247,35 +1279,36 @@ bool CTxDB::LoadBlockIndexGuts()
if (pindexNew->IsProofOfStake())
setStakeSeen.insert(make_pair(pindexNew->prevoutStake, pindexNew->nStakeTime));
#ifdef WIN32
if( 0 == ( nCount % 10000 ) ) // every 10,000th time through the loop
// could "guess at the max nHeight & %age against the loop count
// to "hone in on" the %age done.
// Towards the end it ought to be pretty accurate.
if( nMaxHeightGuess < pindexNew->nHeight )
nMaxHeightGuess = pindexNew->nHeight;
if(
( 0 != nCount ) &&
0 == ( nCount % nRefresh )
) // every nRefresh-th time through the loop
{
// could "guess at the max nHeight & %age against the loop count
// to "hone in on" the %age done. Towards the end it ought to be pretty accurate.
if( nMaxHeightGuess < pindexNew->nHeight )
nMaxHeightGuess = pindexNew->nHeight;
if( 0 != nCount )
{
std::string
sGutsNoise = strprintf(
"%7d (%2.2f%%)"
"",
pindexNew->nHeight
, // these #s are just to slosh the . around
(floorf( float(nCount * 10000.0 / nMaxHeightGuess) ) / 100) > 100.0?
100.0: (floorf( float(nCount * 10000.0 / nMaxHeightGuess) ) / 100)
);
if (fPrintToConsole)
(void)printf(
"%s"
""
"\r"
"",
sGutsNoise.c_str()
);
float // these #s are just to slosh the . around
dEstimate = float( ( 100.0 * nCount ) / nMaxHeightGuess );
std::string
sGutsNoise = strprintf(
"%7d (%3.2f%%)"
"",
pindexNew->nHeight,
dEstimate > 100.0? 100.0: dEstimate
);
if (fPrintToConsole)
(void)printf(
"%s"
" "
"\r"
"",
sGutsNoise.c_str()
);
#ifdef QT_GUI
uiInterface.InitMessage( sGutsNoise.c_str() );
uiInterface.InitMessage( sGutsNoise.c_str() );
#endif
}
}
++nCount;
#endif
Expand Down
9 changes: 9 additions & 0 deletions src/json/json_spirit_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

// json spirit version 4.03

#ifdef _MSC_VER
#include <stdint.h>

#include "msvc_warnings.push.h"
#endif

#include "json_spirit_writer.h"
#include "json_spirit_writer_template.h"

Expand Down Expand Up @@ -93,3 +99,6 @@ std::wstring json_spirit::write_formatted( const wmValue& value )
}

#endif
#ifdef _MSC_VER
#include "msvc_warnings.pop.h"
#endif
4 changes: 3 additions & 1 deletion src/json/json_spirit_writer_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.03
#include "util.h"

#include "json_spirit_value.h"

#include "..\util.h"
//extern const int COINdecimalPower;

#include <cassert>
#include <sstream>
#include <iomanip>
Expand Down
Loading

0 comments on commit 8aefde6

Please sign in to comment.