{ "getbestblockhash", &getbestblockhash, true, false },
{ "getblockcount", &getblockcount, true, false },
{ "getconnectioncount", &getconnectioncount, true, false },
+ { "getaddrmaninfo", &getaddrmaninfo, true, false },
{ "getpeerinfo", &getpeerinfo, true, false },
{ "addnode", &addnode, true, true },
{ "getaddednodeinfo", &getaddednodeinfo, true, true },
extern json_spirit::Value getconnectioncount(const json_spirit::Array& params, bool fHelp); // in rpcnet.cpp
extern json_spirit::Value getpeerinfo(const json_spirit::Array& params, bool fHelp);
+extern json_spirit::Value getaddrmaninfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value addnode(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value dumpwallet(const json_spirit::Array& params, bool fHelp);
}
// Scan given coins set for kernel solution
-bool ScanForStakeKernelHash(MetaMap &mapMeta, KernelSearchSettings &settings, CoinsSet::value_type &kernelcoin, uint32_t &nTimeTx, uint32_t &nBlockTime, uint64_t &nKernelsTried, uint64_t &nCoinDaysTried)
+bool ScanForStakeKernelHash(MetaMap &mapMeta, uint32_t nBits, uint32_t nTime, uint32_t nSearchInterval, CoinsSet::value_type &kernelcoin, uint32_t &nTimeTx, uint32_t &nBlockTime, uint64_t &nKernelsTried, uint64_t &nCoinDaysTried)
{
uint256 hashProofOfStake = 0;
// Get coin
CoinsSet::value_type pcoin = meta_item->second.first.second;
- static int nMaxStakeSearchInterval = 60;
+ static unsigned int nMaxStakeSearchInterval = 60;
// only count coins meeting min age requirement
- if (nStakeMinAge + block.nTime > settings.nTime - nMaxStakeSearchInterval)
+ if (nStakeMinAge + block.nTime > nTime - nMaxStakeSearchInterval)
continue;
// Transaction offset inside block
uint32_t nTxOffset = txindex.pos.nTxPos - txindex.pos.nBlockPos;
// Current timestamp scanning interval
- unsigned int nCurrentSearchInterval = min((int64_t)settings.nSearchInterval, (int64_t)nMaxStakeSearchInterval);
+ unsigned int nCurrentSearchInterval = min(nSearchInterval, nMaxStakeSearchInterval);
nBlockTime = block.nTime;
CBigNum bnTargetPerCoinDay;
- bnTargetPerCoinDay.SetCompact(settings.nBits);
+ bnTargetPerCoinDay.SetCompact(nBits);
int64_t nValueIn = pcoin.first->vout[pcoin.second].nValue;
// Search backward in time from the given timestamp
// Stopping search in case of shutting down or cache invalidation
for (unsigned int n=0; n<nCurrentSearchInterval && fCoinsDataActual && !fShutdown; n++)
{
- nTimeTx = settings.nTime - n;
+ nTimeTx = nTime - n;
CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)pcoin.first->nTime, (int64_t)nTimeTx) / COIN / (24 * 60 * 60);
CBigNum bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay;
// Sets hashProofOfStake on success return
bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, uint32_t nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, uint32_t nTimeTx, uint256& hashProofOfStake, uint256& targetProofOfStake, bool fPrintProofOfStake=false);
-// Coins scanning options
-typedef struct KernelSearchSettings {
- uint32_t nBits; // Packed difficulty
- uint32_t nTime; // Basic time
- uint32_t nOffset; // Offset inside CoinsSet (isn't used yet)
- uint32_t nLimit; // Coins to scan (isn't used yet)
- uint32_t nSearchInterval; // Number of seconds allowed to go into the past
-} KernelSearchSettings;
-
-typedef std::set<std::pair<const CWalletTx*,unsigned int> > CoinsSet;
-
-// Preloaded coins metadata
-// txid => ((txindex, (tx, vout.n)), (block, modifier))
-typedef std::map<std::pair<uint256, unsigned int>, std::pair<std::pair<CTxIndex, std::pair<const CWalletTx*,unsigned int> >, std::pair<CBlock, uint64_t> > > MetaMap;
-
// Scan given coins set for kernel solution
-bool ScanForStakeKernelHash(MetaMap &mapMeta, KernelSearchSettings &settings, CoinsSet::value_type &kernelcoin, uint32_t &nTimeTx, uint32_t &nBlockTime, uint64_t &nKernelsTried, uint64_t &nCoinDaysTried);
+bool ScanForStakeKernelHash(MetaMap &mapMeta, uint32_t nBits, uint32_t nTime, uint32_t nSearchInterval, CoinsSet::value_type &kernelcoin, uint32_t &nTimeTx, uint32_t &nBlockTime, uint64_t &nKernelsTried, uint64_t &nCoinDaysTried);
// Check kernel hash target and coinstake signature
// Sets hashProofOfStake on success return
if (IsProofOfStake())
return true;
- static int64_t nLastCoinStakeSearchTime = GetAdjustedTime(); // startup timestamp
+ static uint32_t nLastCoinStakeSearchTime = GetAdjustedTime(); // startup timestamp
CKey key;
CTransaction txCoinStake;
- int64_t nSearchTime = txCoinStake.nTime; // search to current time
+ uint32_t nSearchTime = txCoinStake.nTime; // search to current time
if (nSearchTime > nLastCoinStakeSearchTime)
{
extern unsigned int nTransactionsUpdated;
extern uint64_t nLastBlockTx;
extern uint64_t nLastBlockSize;
-extern int64_t nLastCoinStakeSearchInterval;
+extern uint32_t nLastCoinStakeSearchInterval;
extern const std::string strMessageMagic;
extern int64_t nTimeBestReceived;
extern CCriticalSection cs_setpwalletRegistered;
uint64_t nLastBlockTx = 0;
uint64_t nLastBlockSize = 0;
-int64_t nLastCoinStakeSearchInterval = 0;
+uint32_t nLastCoinStakeSearchInterval = 0;
// We want to sort transactions by priority and fee, so:
typedef boost::tuple<double, double, CTransaction*> TxPriority;
}
}
+Value getaddrmaninfo(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 0)
+ throw runtime_error(
+ "getaddrmaninfo\n"
+ "Returns a dump of addrman data.");
+
+ vector<CAddress> vAddr = addrman.GetAddr();
+
+ Array ret;
+
+ BOOST_FOREACH(const CAddress &addr, vAddr) {
+ // Don't return addresses older than nCutOff timestamp
+ int64_t nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60);
+
+ if (!addr.IsRoutable() || addr.IsLocal() || addr.nTime > nCutOff)
+ continue;
+
+ Object addrManItem;
+ addrManItem.push_back(Pair("address", addr.ToString()));
+
+ string strNetType;
+ switch(addr.GetNetwork())
+ {
+ case NET_TOR:
+ strNetType = "tor";
+ break;
+ case NET_I2P:
+ strNetType = "i2p";
+ case NET_IPV4:
+ strNetType = "ipv4";
+ break;
+ default:
+ case NET_IPV6:
+ strNetType = "ipv6";
+
+ }
+ addrManItem.push_back(Pair("type", strNetType));
+ addrManItem.push_back(Pair("time", (int64_t)addr.nTime));
+
+ ret.push_back(addrManItem);
+ }
+
+ return ret;
+}
+
Value getpeerinfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
}
-bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CTransaction& txNew, CKey& key)
+bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, uint32_t nSearchInterval, CTransaction& txNew, CKey& key)
{
// The following combine threshold is important to security
// Should not be adjusted if you don't understand the consequences
int64_t nCredit = 0;
CScript scriptPubKeyKernel;
- KernelSearchSettings settings;
- settings.nBits = nBits;
- settings.nTime = txNew.nTime;
- settings.nOffset = 0;
- settings.nLimit = mapMeta.size();
- settings.nSearchInterval = nSearchInterval;
-
unsigned int nTimeTx, nBlockTime;
COutPoint prevoutStake;
CoinsSet::value_type kernelcoin;
- if (ScanForStakeKernelHash(mapMeta, settings, kernelcoin, nTimeTx, nBlockTime, nKernelsTried, nCoinDaysTried))
+ if (ScanForStakeKernelHash(mapMeta, nBits, txNew.nTime, nSearchInterval, kernelcoin, nTimeTx, nBlockTime, nKernelsTried, nCoinDaysTried))
{
// Found a kernel
if (fDebug && GetBoolArg("-printcoinstake"))
{
{
LOCK(cs_wallet);
- if (block.IsProofOfWork() && mapWallet.count(block.vtx[0].GetHash()))
- {
- CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()];
- printf(" mine: %d %d %" PRId64 "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit(MINE_ALL));
- }
if (block.IsProofOfStake() && mapWallet.count(block.vtx[1].GetHash()))
{
CWalletTx& wtx = mapWallet[block.vtx[1].GetHash()];
- printf(" stake: %d %d %" PRId64 "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit(MINE_ALL));
- }
-
+ printf(" PoS: %d %d %" PRId64 "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit(MINE_ALL));
+ }
+ else if (mapWallet.count(block.vtx[0].GetHash()))
+ {
+ CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()];
+ printf(" PoW: %d %d %" PRId64 "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit(MINE_ALL));
+ }
}
printf("\n");
}
class COutput;
class CCoinControl;
+// Set of selected transactions
+typedef std::set<std::pair<const CWalletTx*,unsigned int> > CoinsSet;
+
+// Preloaded coins metadata
+// (txid, vout.n) => ((txindex, (tx, vout.n)), (block, modifier))
+typedef std::map<std::pair<uint256, unsigned int>, std::pair<std::pair<CTxIndex, std::pair<const CWalletTx*,unsigned int> >, std::pair<CBlock, uint64_t> > > MetaMap;
+
+
/** (client) version numbers for particular wallet features */
enum WalletFeature
{
void GetStakeStats(float &nKernelsRate, float &nCoinDaysRate);
void GetStakeWeightFromValue(const int64_t& nTime, const int64_t& nValue, uint64_t& nWeight);
- bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CTransaction& txNew, CKey& key);
+ bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, uint32_t nSearchInterval, CTransaction& txNew, CKey& key);
bool MergeCoins(const int64_t& nAmount, const int64_t& nMinValue, const int64_t& nMaxValue, std::list<uint256>& listMerged);
std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);