mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 05:23:01 +01:00
merge downstream 0.11.1
This commit is contained in:
commit
8fc3f84ad8
@ -3,7 +3,7 @@ AC_PREREQ([2.60])
|
|||||||
define(_CLIENT_VERSION_MAJOR, 0)
|
define(_CLIENT_VERSION_MAJOR, 0)
|
||||||
define(_CLIENT_VERSION_MINOR, 11)
|
define(_CLIENT_VERSION_MINOR, 11)
|
||||||
define(_CLIENT_VERSION_REVISION, 1)
|
define(_CLIENT_VERSION_REVISION, 1)
|
||||||
define(_CLIENT_VERSION_BUILD, 8)
|
define(_CLIENT_VERSION_BUILD, 10)
|
||||||
define(_CLIENT_VERSION_IS_RELEASE, true)
|
define(_CLIENT_VERSION_IS_RELEASE, true)
|
||||||
define(_COPYRIGHT_YEAR, 2015)
|
define(_COPYRIGHT_YEAR, 2015)
|
||||||
AC_INIT([Darkcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@darkcoin.io],[darkcoin])
|
AC_INIT([Darkcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@darkcoin.io],[darkcoin])
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#define CLIENT_VERSION_MAJOR 0
|
#define CLIENT_VERSION_MAJOR 0
|
||||||
#define CLIENT_VERSION_MINOR 11
|
#define CLIENT_VERSION_MINOR 11
|
||||||
#define CLIENT_VERSION_REVISION 1
|
#define CLIENT_VERSION_REVISION 1
|
||||||
#define CLIENT_VERSION_BUILD 8
|
#define CLIENT_VERSION_BUILD 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
std::string COutPoint::ToString() const
|
std::string COutPoint::ToString() const
|
||||||
|
@ -19,7 +19,8 @@ static const int64_t DARKSEND_COLLATERAL = (0.1*COIN);
|
|||||||
static const int64_t DARKSEND_FEE = (0.0125*COIN);
|
static const int64_t DARKSEND_FEE = (0.0125*COIN);
|
||||||
static const int64_t DARKSEND_POOL_MAX = (999.99*COIN);
|
static const int64_t DARKSEND_POOL_MAX = (999.99*COIN);
|
||||||
|
|
||||||
#define INSTANTX_SIGNATURES_REQUIRED 9
|
#define INSTANTX_SIGNATURES_REQUIRED 6
|
||||||
|
#define INSTANTX_SIGNATURES_TOTAL 10
|
||||||
|
|
||||||
#define MASTERNODE_NOT_PROCESSED 0 // initial state
|
#define MASTERNODE_NOT_PROCESSED 0 // initial state
|
||||||
#define MASTERNODE_IS_CAPABLE 1
|
#define MASTERNODE_IS_CAPABLE 1
|
||||||
|
@ -1319,41 +1319,6 @@ bool CDarkSendPool::GetBlockHash(uint256& hash, int nBlockHeight)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the last hash that matches the modulus given. Processed in reverse order
|
|
||||||
bool CDarkSendPool::GetLastValidBlockHash(uint256& hash, int mod, int nBlockHeight)
|
|
||||||
{
|
|
||||||
if(unitTest){
|
|
||||||
hash.SetHex("00000000001432b4910722303bff579d0445fa23325bdc34538bdb226718ba79");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CBlockIndex *BlockLastSolved = chainActive.Tip();
|
|
||||||
const CBlockIndex *BlockReading = chainActive.Tip();
|
|
||||||
|
|
||||||
if (chainActive.Tip() == NULL) return false;
|
|
||||||
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || chainActive.Tip()->nHeight+1 < nBlockHeight) return false;
|
|
||||||
|
|
||||||
int nBlocksAgo = 0;
|
|
||||||
if(nBlockHeight > 0) nBlocksAgo = (chainActive.Tip()->nHeight+1)-nBlockHeight;
|
|
||||||
assert(nBlocksAgo >= 0);
|
|
||||||
|
|
||||||
int n = 0;
|
|
||||||
for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) {
|
|
||||||
if(BlockReading->nHeight % mod == 0) {
|
|
||||||
if(n >= nBlocksAgo){
|
|
||||||
hash = BlockReading->GetBlockHash();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BlockReading->pprev == NULL) { assert(BlockReading); break; }
|
|
||||||
BlockReading = BlockReading->pprev;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDarkSendPool::NewBlock()
|
void CDarkSendPool::NewBlock()
|
||||||
{
|
{
|
||||||
if(fDebug) LogPrintf("CDarkSendPool::NewBlock \n");
|
if(fDebug) LogPrintf("CDarkSendPool::NewBlock \n");
|
||||||
|
@ -222,7 +222,7 @@ class CDarksendSession
|
|||||||
class CDarkSendPool
|
class CDarkSendPool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const int MIN_PEER_PROTO_VERSION = 70058;
|
static const int MIN_PEER_PROTO_VERSION = 70060;
|
||||||
|
|
||||||
// clients entries
|
// clients entries
|
||||||
std::vector<CDarkSendEntry> myEntries;
|
std::vector<CDarkSendEntry> myEntries;
|
||||||
|
@ -702,7 +702,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//ignore masternodes below protocol version
|
//ignore masternodes below protocol version
|
||||||
nMasternodeMinProtocol = GetArg("-masternodeminprotocol", 0);
|
nMasternodeMinProtocol = GetArg("-masternodeminprotocol", 70051);
|
||||||
|
|
||||||
int64_t nStart;
|
int64_t nStart;
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ int nCompleteTXLocks;
|
|||||||
void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
|
void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
if(fLiteMode) return; //disable all darksend/masternode related functionality
|
if(fLiteMode) return; //disable all darksend/masternode related functionality
|
||||||
|
if(fLargeWorkForkFound || fLargeWorkInvalidChainFound) return;
|
||||||
|
|
||||||
if (strCommand == "txlreq")
|
if (strCommand == "txlreq")
|
||||||
{
|
{
|
||||||
@ -104,6 +105,7 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
|
|||||||
if (i != mapTxLocks.end()){
|
if (i != mapTxLocks.end()){
|
||||||
//we only care if we have a complete tx lock
|
//we only care if we have a complete tx lock
|
||||||
if((*i).second.CountSignatures() >= INSTANTX_SIGNATURES_REQUIRED){
|
if((*i).second.CountSignatures() >= INSTANTX_SIGNATURES_REQUIRED){
|
||||||
|
if(!CheckForConflictingLocks(tx)){
|
||||||
LogPrintf("ProcessMessageInstantX::txlreq - Found Existing Complete IX Lock\n");
|
LogPrintf("ProcessMessageInstantX::txlreq - Found Existing Complete IX Lock\n");
|
||||||
|
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
@ -111,6 +113,7 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
|
|||||||
mapTxLockReq.insert(make_pair(tx.GetHash(), tx));
|
mapTxLockReq.insert(make_pair(tx.GetHash(), tx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -229,7 +232,8 @@ int64_t CreateNewLock(CTransaction tx)
|
|||||||
|
|
||||||
CTransactionLock newLock;
|
CTransactionLock newLock;
|
||||||
newLock.nBlockHeight = nBlockHeight;
|
newLock.nBlockHeight = nBlockHeight;
|
||||||
newLock.nExpiration = GetTime()+(60*60);
|
newLock.nExpiration = GetTime()+(60*15); //locks expire after 15 minutes (6 confirmations)
|
||||||
|
newLock.nTimeout = GetTime()+(60*5);
|
||||||
newLock.txHash = tx.GetHash();
|
newLock.txHash = tx.GetHash();
|
||||||
mapTxLocks.insert(make_pair(tx.GetHash(), newLock));
|
mapTxLocks.insert(make_pair(tx.GetHash(), newLock));
|
||||||
} else {
|
} else {
|
||||||
@ -282,9 +286,9 @@ bool ProcessConsensusVote(CConsensusVote& ctx)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(n > 10)
|
if(n > INSTANTX_SIGNATURES_TOTAL)
|
||||||
{
|
{
|
||||||
LogPrintf("InstantX::ProcessConsensusVote - Masternode not in the top 10 (%d)\n", n);
|
LogPrintf("InstantX::ProcessConsensusVote - Masternode not in the top %d (%d)\n", INSTANTX_SIGNATURES_TOTAL, n);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,6 +304,7 @@ bool ProcessConsensusVote(CConsensusVote& ctx)
|
|||||||
CTransactionLock newLock;
|
CTransactionLock newLock;
|
||||||
newLock.nBlockHeight = 0;
|
newLock.nBlockHeight = 0;
|
||||||
newLock.nExpiration = GetTime()+(60*60);
|
newLock.nExpiration = GetTime()+(60*60);
|
||||||
|
newLock.nTimeout = GetTime()+(60*5);
|
||||||
newLock.txHash = ctx.txHash;
|
newLock.txHash = ctx.txHash;
|
||||||
mapTxLocks.insert(make_pair(ctx.txHash, newLock));
|
mapTxLocks.insert(make_pair(ctx.txHash, newLock));
|
||||||
} else {
|
} else {
|
||||||
@ -311,11 +316,22 @@ bool ProcessConsensusVote(CConsensusVote& ctx)
|
|||||||
if (i != mapTxLocks.end()){
|
if (i != mapTxLocks.end()){
|
||||||
(*i).second.AddSignature(ctx);
|
(*i).second.AddSignature(ctx);
|
||||||
|
|
||||||
|
#ifdef ENABLE_WALLET
|
||||||
|
if(pwalletMain){
|
||||||
|
//when we get back signatures, we'll count them as requests. Otherwise the client will think it didn't propagate.
|
||||||
|
if(pwalletMain->mapRequestCount.count(ctx.txHash))
|
||||||
|
pwalletMain->mapRequestCount[ctx.txHash]++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Transaction Lock Votes %d - %s !\n", (*i).second.CountSignatures(), ctx.GetHash().ToString().c_str());
|
if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Transaction Lock Votes %d - %s !\n", (*i).second.CountSignatures(), ctx.GetHash().ToString().c_str());
|
||||||
|
|
||||||
if((*i).second.CountSignatures() >= INSTANTX_SIGNATURES_REQUIRED){
|
if((*i).second.CountSignatures() >= INSTANTX_SIGNATURES_REQUIRED){
|
||||||
if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Transaction Lock Is Complete %s !\n", (*i).second.GetHash().ToString().c_str());
|
if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Transaction Lock Is Complete %s !\n", (*i).second.GetHash().ToString().c_str());
|
||||||
|
|
||||||
|
CTransaction& tx = mapTxLockReq[ctx.txHash];
|
||||||
|
if(!CheckForConflictingLocks(tx)){
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if(pwalletMain){
|
if(pwalletMain){
|
||||||
if(pwalletMain->UpdatedTransaction((*i).second.txHash)){
|
if(pwalletMain->UpdatedTransaction((*i).second.txHash)){
|
||||||
@ -325,7 +341,6 @@ bool ProcessConsensusVote(CConsensusVote& ctx)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(mapTxLockReq.count(ctx.txHash)){
|
if(mapTxLockReq.count(ctx.txHash)){
|
||||||
CTransaction& tx = mapTxLockReq[ctx.txHash];
|
|
||||||
BOOST_FOREACH(const CTxIn& in, tx.vin){
|
BOOST_FOREACH(const CTxIn& in, tx.vin){
|
||||||
if(!mapLockedInputs.count(in.prevout)){
|
if(!mapLockedInputs.count(in.prevout)){
|
||||||
mapLockedInputs.insert(make_pair(in.prevout, ctx.txHash));
|
mapLockedInputs.insert(make_pair(in.prevout, ctx.txHash));
|
||||||
@ -341,6 +356,7 @@ bool ProcessConsensusVote(CConsensusVote& ctx)
|
|||||||
DisconnectBlockAndInputs(state, mapTxLockReqRejected[(*i).second.txHash]);
|
DisconnectBlockAndInputs(state, mapTxLockReqRejected[(*i).second.txHash]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,6 +364,28 @@ bool ProcessConsensusVote(CConsensusVote& ctx)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CheckForConflictingLocks(CTransaction& tx)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
It's possible (very unlikely though) to get 2 conflicting transaction locks approved by the network.
|
||||||
|
In that case, they will cancel each other out.
|
||||||
|
|
||||||
|
Blocks could have been rejected during this time, which is OK. After they cancel out, the client will
|
||||||
|
rescan the blocks and find they're acceptable and then take the chain with the most work.
|
||||||
|
*/
|
||||||
|
BOOST_FOREACH(const CTxIn& in, tx.vin){
|
||||||
|
if(mapLockedInputs.count(in.prevout)){
|
||||||
|
if(mapLockedInputs[in.prevout] != tx.GetHash()){
|
||||||
|
LogPrintf("InstantX::CheckForConflictingLocks - found two complete conflicting locks - removing both. %s %s", tx.GetHash().ToString().c_str(), mapLockedInputs[in.prevout].ToString().c_str());
|
||||||
|
if(mapTxLocks.count(tx.GetHash())) mapTxLocks[tx.GetHash()].nExpiration = GetTime();
|
||||||
|
if(mapTxLocks.count(mapLockedInputs[in.prevout])) mapTxLocks[mapLockedInputs[in.prevout]].nExpiration = GetTime();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t GetAverageVoteTime()
|
int64_t GetAverageVoteTime()
|
||||||
{
|
{
|
||||||
@ -481,9 +519,9 @@ bool CTransactionLock::SignaturesValid()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(n > 10)
|
if(n > INSTANTX_SIGNATURES_TOTAL)
|
||||||
{
|
{
|
||||||
LogPrintf("InstantX::DoConsensusVote - Masternode not in the top 10\n");
|
LogPrintf("InstantX::DoConsensusVote - Masternode not in the top %s\n", INSTANTX_SIGNATURES_TOTAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,6 +541,9 @@ void CTransactionLock::AddSignature(CConsensusVote cv)
|
|||||||
|
|
||||||
int CTransactionLock::CountSignatures()
|
int CTransactionLock::CountSignatures()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
return 10;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Only count signatures where the BlockHeight matches the transaction's blockheight.
|
Only count signatures where the BlockHeight matches the transaction's blockheight.
|
||||||
The votes have no proof it's the correct blockheight
|
The votes have no proof it's the correct blockheight
|
||||||
|
@ -23,7 +23,7 @@ class CConsensusVote;
|
|||||||
class CTransaction;
|
class CTransaction;
|
||||||
class CTransactionLock;
|
class CTransactionLock;
|
||||||
|
|
||||||
static const int MIN_INSTANTX_PROTO_VERSION = 70058;
|
static const int MIN_INSTANTX_PROTO_VERSION = 70060;
|
||||||
|
|
||||||
extern map<uint256, CTransaction> mapTxLockReq;
|
extern map<uint256, CTransaction> mapTxLockReq;
|
||||||
extern map<uint256, CTransactionLock> mapTxLocks;
|
extern map<uint256, CTransactionLock> mapTxLocks;
|
||||||
@ -35,6 +35,9 @@ int64_t CreateNewLock(CTransaction tx);
|
|||||||
|
|
||||||
bool IsIXTXValid(const CTransaction& txCollateral);
|
bool IsIXTXValid(const CTransaction& txCollateral);
|
||||||
|
|
||||||
|
// if two conflicting locks are approved by the network, they will cancel out
|
||||||
|
bool CheckForConflictingLocks(CTransaction& tx);
|
||||||
|
|
||||||
void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
||||||
|
|
||||||
//check if we need to vote on this transaction
|
//check if we need to vote on this transaction
|
||||||
@ -77,6 +80,7 @@ public:
|
|||||||
uint256 txHash;
|
uint256 txHash;
|
||||||
std::vector<CConsensusVote> vecConsensusVotes;
|
std::vector<CConsensusVote> vecConsensusVotes;
|
||||||
int nExpiration;
|
int nExpiration;
|
||||||
|
int nTimeout;
|
||||||
|
|
||||||
bool SignaturesValid();
|
bool SignaturesValid();
|
||||||
int CountSignatures();
|
int CountSignatures();
|
||||||
|
39
src/main.cpp
39
src/main.cpp
@ -1170,23 +1170,31 @@ int CMerkleTx::GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const
|
|||||||
return chainActive.Height() - pindex->nHeight + 1;
|
return chainActive.Height() - pindex->nHeight + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMerkleTx::IsTransactionLocked() const
|
int CMerkleTx::GetTransactionLockSignatures() const
|
||||||
|
{
|
||||||
|
if(fLargeWorkForkFound || fLargeWorkInvalidChainFound) return -2;
|
||||||
|
if(nInstantXDepth == 0) return -1;
|
||||||
|
|
||||||
|
//compile consessus vote
|
||||||
|
std::map<uint256, CTransactionLock>::iterator i = mapTxLocks.find(GetHash());
|
||||||
|
if (i != mapTxLocks.end()){
|
||||||
|
return (*i).second.CountSignatures();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMerkleTx::IsTransactionLockTimedOut() const
|
||||||
{
|
{
|
||||||
if(nInstantXDepth == 0) return 0;
|
if(nInstantXDepth == 0) return 0;
|
||||||
|
|
||||||
//compile consessus vote
|
//compile consessus vote
|
||||||
std::map<uint256, CTransactionLock>::iterator i = mapTxLocks.find(GetHash());
|
std::map<uint256, CTransactionLock>::iterator i = mapTxLocks.find(GetHash());
|
||||||
if (i != mapTxLocks.end()){
|
if (i != mapTxLocks.end()){
|
||||||
if((*i).second.CountSignatures() >= INSTANTX_SIGNATURES_REQUIRED){
|
return GetTime() > (*i).second.nTimeout;
|
||||||
LogPrintf("InstantX::ProcessConsensusVote - Transaction Lock Is Complete %s\n", (*i).second.GetHash().ToString().c_str());
|
|
||||||
return nInstantXDepth;
|
|
||||||
} else {
|
|
||||||
LogPrintf("InstantX::ProcessConsensusVote - Incomplete TX Lock %d %s\n", (*i).second.CountSignatures(), (*i).second.GetHash().ToString().c_str());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMerkleTx::GetDepthInMainChain(CBlockIndex* &pindexRet, bool enableIX) const
|
int CMerkleTx::GetDepthInMainChain(CBlockIndex* &pindexRet, bool enableIX) const
|
||||||
@ -1198,8 +1206,10 @@ int CMerkleTx::GetDepthInMainChain(CBlockIndex* &pindexRet, bool enableIX) const
|
|||||||
|
|
||||||
if(enableIX){
|
if(enableIX){
|
||||||
if (nResult < 6){
|
if (nResult < 6){
|
||||||
int minConfirms = IsTransactionLocked();
|
int signatures = GetTransactionLockSignatures();
|
||||||
return minConfirms+nResult;
|
if(signatures >= INSTANTX_SIGNATURES_REQUIRED){
|
||||||
|
return nInstantXDepth+nResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2815,8 +2825,10 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
|
|||||||
|
|
||||||
// ----------- instantX transaction scanning -----------
|
// ----------- instantX transaction scanning -----------
|
||||||
|
|
||||||
|
if(!fLargeWorkForkFound && !fLargeWorkInvalidChainFound){
|
||||||
BOOST_FOREACH(const CTransaction& tx, block.vtx){
|
BOOST_FOREACH(const CTransaction& tx, block.vtx){
|
||||||
if (!tx.IsCoinBase()){
|
if (!tx.IsCoinBase()){
|
||||||
|
//only reject blocks when it's based on complete consensus
|
||||||
BOOST_FOREACH(const CTxIn& in, tx.vin){
|
BOOST_FOREACH(const CTxIn& in, tx.vin){
|
||||||
if(mapLockedInputs.count(in.prevout)){
|
if(mapLockedInputs.count(in.prevout)){
|
||||||
if(mapLockedInputs[in.prevout] != tx.GetHash()){
|
if(mapLockedInputs[in.prevout] != tx.GetHash()){
|
||||||
@ -2827,6 +2839,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------- masternode payments -----------
|
// ----------- masternode payments -----------
|
||||||
@ -2839,7 +2852,8 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
|
|||||||
if(block.nTime > START_MASTERNODE_PAYMENTS) MasternodePayments = true;
|
if(block.nTime > START_MASTERNODE_PAYMENTS) MasternodePayments = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(MasternodePayments)
|
|
||||||
|
if(MasternodePayments && !fLargeWorkForkFound && !fLargeWorkInvalidChainFound)
|
||||||
{
|
{
|
||||||
LOCK2(cs_main, mempool.cs);
|
LOCK2(cs_main, mempool.cs);
|
||||||
|
|
||||||
@ -3098,6 +3112,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Check for duplicate
|
// Check for duplicate
|
||||||
uint256 hash = pblock->GetHash();
|
uint256 hash = pblock->GetHash();
|
||||||
if (mapBlockIndex.count(hash))
|
if (mapBlockIndex.count(hash))
|
||||||
|
@ -108,6 +108,10 @@ extern int nScriptCheckThreads;
|
|||||||
extern bool fTxIndex;
|
extern bool fTxIndex;
|
||||||
extern unsigned int nCoinCacheSize;
|
extern unsigned int nCoinCacheSize;
|
||||||
|
|
||||||
|
|
||||||
|
extern bool fLargeWorkForkFound;
|
||||||
|
extern bool fLargeWorkInvalidChainFound;
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
@ -485,7 +489,10 @@ public:
|
|||||||
bool IsInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChainINTERNAL(pindexRet) > 0; }
|
bool IsInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChainINTERNAL(pindexRet) > 0; }
|
||||||
int GetBlocksToMaturity() const;
|
int GetBlocksToMaturity() const;
|
||||||
bool AcceptToMemoryPool(bool fLimitFree=true);
|
bool AcceptToMemoryPool(bool fLimitFree=true);
|
||||||
int IsTransactionLocked() const;
|
int GetTransactionLockSignatures() const;
|
||||||
|
bool IsTransactionLockTimedOut() const;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ map<uint256, int> mapSeenMasternodeScanningErrors;
|
|||||||
std::map<CNetAddr, int64_t> askedForMasternodeList;
|
std::map<CNetAddr, int64_t> askedForMasternodeList;
|
||||||
// which masternodes we've asked for
|
// which masternodes we've asked for
|
||||||
std::map<COutPoint, int64_t> askedForMasternodeListEntry;
|
std::map<COutPoint, int64_t> askedForMasternodeListEntry;
|
||||||
|
// cache block hashes as we calculate them
|
||||||
|
std::map<int64_t, uint256> mapCacheBlockHashes;
|
||||||
|
|
||||||
// manage the masternode connections
|
// manage the masternode connections
|
||||||
void ProcessMasternodeConnections(){
|
void ProcessMasternodeConnections(){
|
||||||
@ -500,6 +502,40 @@ int GetMasternodeRank(CTxIn& vin, int64_t nBlockHeight, int minProtocol)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get the last hash that matches the modulus given. Processed in reverse order
|
||||||
|
bool GetBlockHash(uint256& hash, int nBlockHeight)
|
||||||
|
{
|
||||||
|
if(mapCacheBlockHashes.count(nBlockHeight)){
|
||||||
|
hash = mapCacheBlockHashes[nBlockHeight];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CBlockIndex *BlockLastSolved = chainActive.Tip();
|
||||||
|
const CBlockIndex *BlockReading = chainActive.Tip();
|
||||||
|
|
||||||
|
if (chainActive.Tip() == NULL) return false;
|
||||||
|
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || chainActive.Tip()->nHeight+1 < nBlockHeight) return false;
|
||||||
|
|
||||||
|
int nBlocksAgo = 0;
|
||||||
|
if(nBlockHeight > 0) nBlocksAgo = (chainActive.Tip()->nHeight+1)-nBlockHeight;
|
||||||
|
assert(nBlocksAgo >= 0);
|
||||||
|
|
||||||
|
int n = 0;
|
||||||
|
for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) {
|
||||||
|
if(n >= nBlocksAgo){
|
||||||
|
hash = BlockReading->GetBlockHash();
|
||||||
|
mapCacheBlockHashes[nBlockHeight-n] = hash;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
n++;
|
||||||
|
|
||||||
|
if (BlockReading->pprev == NULL) { assert(BlockReading); break; }
|
||||||
|
BlockReading = BlockReading->pprev;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Deterministically calculate a given "score" for a masternode depending on how close it's hash is to
|
// Deterministically calculate a given "score" for a masternode depending on how close it's hash is to
|
||||||
// the proof of work for that block. The further away they are the better, the furthest will win the election
|
// the proof of work for that block. The further away they are the better, the furthest will win the election
|
||||||
@ -510,8 +546,11 @@ uint256 CMasterNode::CalculateScore(int mod, int64_t nBlockHeight)
|
|||||||
if(chainActive.Tip() == NULL) return 0;
|
if(chainActive.Tip() == NULL) return 0;
|
||||||
|
|
||||||
uint256 hash = 0;
|
uint256 hash = 0;
|
||||||
if(!darkSendPool.GetLastValidBlockHash(hash, mod, nBlockHeight)) return 0;
|
uint256 aux = vin.prevout.hash;
|
||||||
|
|
||||||
|
if(!GetBlockHash(hash, nBlockHeight)) return 0;
|
||||||
uint256 hash2 = HashX11(BEGIN(hash), END(hash));
|
uint256 hash2 = HashX11(BEGIN(hash), END(hash));
|
||||||
|
uint256 hash3 = HashX11(BEGIN(hash), END(aux));
|
||||||
|
|
||||||
// we'll make a 4 dimensional point in space
|
// we'll make a 4 dimensional point in space
|
||||||
// the closest masternode to that point wins
|
// the closest masternode to that point wins
|
||||||
@ -528,11 +567,11 @@ uint256 CMasterNode::CalculateScore(int mod, int64_t nBlockHeight)
|
|||||||
memcpy(&i3, &a3, 1);
|
memcpy(&i3, &a3, 1);
|
||||||
memcpy(&i4, &a4, 1);
|
memcpy(&i4, &a4, 1);
|
||||||
|
|
||||||
//split up our mn hash
|
//split up our mn-hash+aux into 4
|
||||||
uint64_t b1 = vin.prevout.hash.Get64(0);
|
uint64_t b1 = hash3.Get64(0);
|
||||||
uint64_t b2 = vin.prevout.hash.Get64(1);
|
uint64_t b2 = hash3.Get64(1);
|
||||||
uint64_t b3 = vin.prevout.hash.Get64(2);
|
uint64_t b3 = hash3.Get64(2);
|
||||||
uint64_t b4 = vin.prevout.hash.Get64(3);
|
uint64_t b4 = hash3.Get64(3);
|
||||||
|
|
||||||
//move mn hash around
|
//move mn hash around
|
||||||
b1 <<= (i1 % 64);
|
b1 <<= (i1 % 64);
|
||||||
|
@ -42,6 +42,7 @@ extern std::vector<CMasterNode> vecMasternodes;
|
|||||||
extern CMasternodePayments masternodePayments;
|
extern CMasternodePayments masternodePayments;
|
||||||
extern std::vector<CTxIn> vecMasternodeAskedFor;
|
extern std::vector<CTxIn> vecMasternodeAskedFor;
|
||||||
extern map<uint256, int> mapSeenMasternodeVotes;
|
extern map<uint256, int> mapSeenMasternodeVotes;
|
||||||
|
extern map<int64_t, uint256> mapCacheBlockHashes;
|
||||||
|
|
||||||
|
|
||||||
// manage the masternode connections
|
// manage the masternode connections
|
||||||
|
@ -540,6 +540,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
//
|
//
|
||||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||||
|
if(!pindexPrev) break;
|
||||||
|
|
||||||
auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
|
auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
|
||||||
if (!pblocktemplate.get())
|
if (!pblocktemplate.get())
|
||||||
@ -547,6 +548,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
CBlock *pblock = &pblocktemplate->block;
|
CBlock *pblock = &pblocktemplate->block;
|
||||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||||
|
|
||||||
|
|
||||||
LogPrintf("Running DarkcoinMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
|
LogPrintf("Running DarkcoinMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
|
||||||
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
|
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
|
||||||
|
|
||||||
|
@ -1869,9 +1869,6 @@ void RelayTransactionLockReq(const CTransaction& tx, const uint256& hash, bool r
|
|||||||
if(!relayToAll && !pnode->fRelayTxes)
|
if(!relayToAll && !pnode->fRelayTxes)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//there's no requests for transactions locks, so we should show it was propagated correctly
|
|
||||||
//pwalletMain->mapRequestCount[tx.GetHash()]++;
|
|
||||||
|
|
||||||
pnode->PushMessage("txlreq", tx);
|
pnode->PushMessage("txlreq", tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>960</width>
|
<width>960</width>
|
||||||
<height>541</height>
|
<height>585</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -326,7 +326,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>24</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -287,13 +287,22 @@ void OverviewPage::updateDarksendProgress()
|
|||||||
|
|
||||||
// calculate parts of the progress, each of them shouldn't be higher than 1:
|
// calculate parts of the progress, each of them shouldn't be higher than 1:
|
||||||
// mixing progress of denominated balance
|
// mixing progress of denominated balance
|
||||||
float denomPart = (float)pwalletMain->GetNormalizedAnonymizedBalance() / pwalletMain->GetDenominatedBalance();
|
int64_t denominatedBalance = pwalletMain->GetDenominatedBalance();
|
||||||
|
float denomPart = 0;
|
||||||
|
if(denominatedBalance > 0)
|
||||||
|
{
|
||||||
|
denomPart = (float)pwalletMain->GetNormalizedAnonymizedBalance() / pwalletMain->GetDenominatedBalance();
|
||||||
denomPart = denomPart > 1 ? 1 : denomPart;
|
denomPart = denomPart > 1 ? 1 : denomPart;
|
||||||
|
}
|
||||||
|
|
||||||
// % of fully anonymized balance
|
// % of fully anonymized balance
|
||||||
float anonPart = (float)pwalletMain->GetAnonymizedBalance() / nMaxToAnonymize;
|
float anonPart = 0;
|
||||||
|
if(nMaxToAnonymize > 0)
|
||||||
|
{
|
||||||
|
anonPart = (float)pwalletMain->GetAnonymizedBalance() / nMaxToAnonymize;
|
||||||
// if anonPart is > 1 then we are done, make denomPart equal 1 too
|
// if anonPart is > 1 then we are done, make denomPart equal 1 too
|
||||||
anonPart = anonPart > 1 ? (denomPart = 1, 1) : anonPart;
|
anonPart = anonPart > 1 ? (denomPart = 1, 1) : anonPart;
|
||||||
|
}
|
||||||
|
|
||||||
// apply some weights to them (sum should be <=100) and calculate the whole progress
|
// apply some weights to them (sum should be <=100) and calculate the whole progress
|
||||||
int progress = 80 * denomPart + 20 * anonPart;
|
int progress = 80 * denomPart + 20 * anonPart;
|
||||||
|
@ -31,8 +31,11 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int signatures = wtx.GetTransactionLockSignatures();
|
||||||
QString strUsingIX = "";
|
QString strUsingIX = "";
|
||||||
if(wtx.IsTransactionLocked()){
|
if(signatures >= 0){
|
||||||
|
|
||||||
|
if(signatures >= INSTANTX_SIGNATURES_REQUIRED){
|
||||||
int nDepth = wtx.GetDepthInMainChain();
|
int nDepth = wtx.GetDepthInMainChain();
|
||||||
if (nDepth < 0)
|
if (nDepth < 0)
|
||||||
return tr("conflicted");
|
return tr("conflicted");
|
||||||
@ -42,6 +45,29 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
|
|||||||
return tr("%1/confirmed (verified via instantx)").arg(nDepth);
|
return tr("%1/confirmed (verified via instantx)").arg(nDepth);
|
||||||
else
|
else
|
||||||
return tr("%1 confirmations (verified via instantx)").arg(nDepth);
|
return tr("%1 confirmations (verified via instantx)").arg(nDepth);
|
||||||
|
} else {
|
||||||
|
if(!wtx.IsTransactionLockTimedOut()){
|
||||||
|
int nDepth = wtx.GetDepthInMainChain();
|
||||||
|
if (nDepth < 0)
|
||||||
|
return tr("conflicted");
|
||||||
|
else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
|
||||||
|
return tr("%1/offline (InstantX verification in progress - %2 of %3 signatures)").arg(nDepth).arg(signatures).arg(INSTANTX_SIGNATURES_TOTAL);
|
||||||
|
else if (nDepth < 6)
|
||||||
|
return tr("%1/confirmed (InstantX verification in progress - %2 of %3 signatures )").arg(nDepth).arg(signatures).arg(INSTANTX_SIGNATURES_TOTAL);
|
||||||
|
else
|
||||||
|
return tr("%1 confirmations (InstantX verification in progress - %2 of %3 signatures)").arg(nDepth).arg(signatures).arg(INSTANTX_SIGNATURES_TOTAL);
|
||||||
|
} else {
|
||||||
|
int nDepth = wtx.GetDepthInMainChain();
|
||||||
|
if (nDepth < 0)
|
||||||
|
return tr("conflicted");
|
||||||
|
else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
|
||||||
|
return tr("%1/offline (InstantX verification failed)").arg(nDepth);
|
||||||
|
else if (nDepth < 6)
|
||||||
|
return tr("%1/confirmed (InstantX verification failed)").arg(nDepth);
|
||||||
|
else
|
||||||
|
return tr("%1 confirmations").arg(nDepth);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
int nDepth = wtx.GetDepthInMainChain();
|
int nDepth = wtx.GetDepthInMainChain();
|
||||||
if (nDepth < 0)
|
if (nDepth < 0)
|
||||||
|
@ -43,7 +43,7 @@ void EnsureWalletIsUnlocked()
|
|||||||
|
|
||||||
void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
|
void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
|
||||||
{
|
{
|
||||||
int confirms = wtx.GetDepthInMainChain();
|
int confirms = wtx.GetDepthInMainChain(false);
|
||||||
entry.push_back(Pair("confirmations", confirms));
|
entry.push_back(Pair("confirmations", confirms));
|
||||||
if (wtx.IsCoinBase())
|
if (wtx.IsCoinBase())
|
||||||
entry.push_back(Pair("generated", true));
|
entry.push_back(Pair("generated", true));
|
||||||
@ -1116,7 +1116,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
|||||||
Object entry;
|
Object entry;
|
||||||
entry.push_back(Pair("account", strSentAccount));
|
entry.push_back(Pair("account", strSentAccount));
|
||||||
MaybePushAddress(entry, s.first);
|
MaybePushAddress(entry, s.first);
|
||||||
entry.push_back(Pair("category", "send"));
|
entry.push_back(Pair("category", wtx.IsDenominated() ? "darksent" : "send"));
|
||||||
entry.push_back(Pair("amount", ValueFromAmount(-s.second)));
|
entry.push_back(Pair("amount", ValueFromAmount(-s.second)));
|
||||||
entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
|
entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
|
||||||
if (fLong)
|
if (fLong)
|
||||||
|
@ -27,13 +27,13 @@ extern const std::string CLIENT_DATE;
|
|||||||
// network protocol versioning
|
// network protocol versioning
|
||||||
//
|
//
|
||||||
|
|
||||||
static const int PROTOCOL_VERSION = 70058;
|
static const int PROTOCOL_VERSION = 70060;
|
||||||
|
|
||||||
// intial proto version, to be increased after version/verack negotiation
|
// intial proto version, to be increased after version/verack negotiation
|
||||||
static const int INIT_PROTO_VERSION = 209;
|
static const int INIT_PROTO_VERSION = 209;
|
||||||
|
|
||||||
// disconnect from peers older than this proto version
|
// disconnect from peers older than this proto version
|
||||||
static const int MIN_PEER_PROTO_VERSION = 70046;
|
static const int MIN_PEER_PROTO_VERSION = 70051;
|
||||||
|
|
||||||
// nTime field added to CAddress, starting with this version;
|
// nTime field added to CAddress, starting with this version;
|
||||||
// if possible, avoid requesting addresses nodes older than this
|
// if possible, avoid requesting addresses nodes older than this
|
||||||
|
Loading…
Reference in New Issue
Block a user