enforcing mixes

This commit is contained in:
Evan Duffield 2014-08-08 12:18:44 -07:00
parent 0aa6d8cfcb
commit 1619683a60
4 changed files with 40 additions and 43 deletions

View File

@ -3965,8 +3965,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
}
printf("new darksend queue object - %s\n", addr.ToString().c_str());
dsq.Relay();
vecDarksendQueue.push_back(dsq);
dsq.Relay();
} else if (strCommand == "dsi") { //DarkSend vIn
if (pfrom->nVersion != darkSendPool.MIN_PEER_PROTO_VERSION) {
@ -4095,7 +4095,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
return false;
}
if(darkSendPool.submittedToMasternode != pfrom->addr){
printf("dssu - message doesn't match current masternode - %s != %s\n", darkSendPool.submittedToMasternode.ToString().c_str(), pfrom->addr.ToString().c_str());
return false;
@ -6241,7 +6240,9 @@ void CDarkSendPool::CheckTimeout(){
}
} else if(GetTimeMillis()-lastTimeChanged >= 30000){
}
if(GetTimeMillis()-lastTimeChanged >= 30000){
if(fDebug) printf("CDarkSendPool::CheckTimeout() -- SESSION TIMED OUT (30) -- RESETTING\n");
SetNull();
UnlockCoins();
@ -6370,7 +6371,7 @@ bool CDarkSendPool::AddEntry(const std::vector<CTxIn>& newInput, const int64& nA
if(entries.size() == 1) {
//broadcast that I'm accepting entries
CDarksendQueue dsq;
dsq.nAmount = nAmount;
dsq.nDenom = GetDenominations(newOutput);
dsq.vin = vinMasterNode;
dsq.time = GetTime();
dsq.Relay();
@ -6904,8 +6905,6 @@ void CDarkSendPool::NewBlock()
if(IsInitialBlockDownload()) return;
printf("CDarkSendPool::NewBlock - 2\n");
{
LOCK2(cs_main, mempool.cs);
if(pindexBest != NULL) {
@ -6921,8 +6920,6 @@ void CDarkSendPool::NewBlock()
}
}
printf("CDarkSendPool::NewBlock - 3\n");
//send votes for next block and one after that
DoConcessusVote(pindexBest->nHeight + 2);
DoConcessusVote(pindexBest->nHeight + 3);
@ -7103,7 +7100,12 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun)
// if we have any pending merges
BOOST_FOREACH(CDarksendQueue dsq, vecDarksendQueue){
CService addr;
if(dsq.time == 0) continue;
if(!dsq.GetAddress(addr)) continue;
if(dsq.nDenom != GetDenominationsByAmount(balanceNeedsAnonymized)) {
printf(" dsq.nDenom != GetDenominationsByAmount %"PRI64d" %d \n", dsq.nDenom, GetDenominationsByAmount(balanceNeedsAnonymized));
continue;
}
dsq.time = 0; //remove node
if(ConnectNode((CAddress)addr, NULL, true)){
@ -7488,42 +7490,16 @@ bool CDarkSendPool::IsCompatibleWithSession(int64 nAmount)
return false;
}
/*CScript e = CScript();
int64 nValueLeft = nAmount;
std::vector<CTxOut> vout1;
BOOST_FOREACH(int64 v, darkSendDenominations){
int nOutputs = 0;
while(nValueLeft - v >= 0 && nOutputs <= 10) {
CTxOut o(v, e);
vout1.push_back(o);
nValueLeft -= v;
nOutputs++;
}
}
nValueLeft = sessionAmount;
std::vector<CTxOut> vout2;
BOOST_FOREACH(int64 v, darkSendDenominations){
int nOutputs = 0;
while(nValueLeft - v >= 0 && nOutputs <= 10) {
CTxOut o(v, e);
vout2.push_back(o);
nValueLeft -= v;
nOutputs++;
}
}
if(GetDenominations(vout1) != GetDenominations(vout2)) return false;
printf("CDarkSendPool::IsCompatibleWithSession - compatible\n");*/
if(GetDenominationsByAmount(nAmount) != GetDenominationsByAmount(sessionAmount)) return false;
printf("CDarkSendPool::IsCompatibleWithSession - compatible\n");
sessionUsers++;
lastTimeChanged = GetTimeMillis();
return true;
}
int CDarkSendPool::GetDenominations(std::vector<CTxOut> vout){
int CDarkSendPool::GetDenominations(const std::vector<CTxOut>& vout){
std::vector<pair<int64, int> > denomUsed;
BOOST_FOREACH(int64 d, darkSendDenominations)
@ -7542,6 +7518,24 @@ int CDarkSendPool::GetDenominations(std::vector<CTxOut> vout){
return denom;
}
int CDarkSendPool::GetDenominationsByAmount(int64 nAmount){
CScript e = CScript();
int64 nValueLeft = nAmount;
std::vector<CTxOut> vout1;
BOOST_FOREACH(int64 v, darkSendDenominations){
int nOutputs = 0;
while(nValueLeft - v >= 0 && nOutputs <= 10) {
CTxOut o(v, e);
vout1.push_back(o);
nValueLeft -= v;
nOutputs++;
}
}
return GetDenominations(vout1);
}
bool CDarkSendSigner::SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey){
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(strSecret);

View File

@ -2570,20 +2570,20 @@ public:
class CDarksendQueue
{
public:
int64 nAmount;
CTxIn vin;
int64 time;
int nDenom;
CDarksendQueue()
{
nAmount = 0;
nDenom = 0;
vin = CTxIn();
time = 0;
}
IMPLEMENT_SERIALIZE
(
READWRITE(nAmount);
READWRITE(nDenom);
READWRITE(vin);
READWRITE(time);
)
@ -2632,7 +2632,7 @@ static const int64 DARKSEND_FEE = 0.001*COIN;
class CDarkSendPool
{
public:
static const int MIN_PEER_PROTO_VERSION = 70029;
static const int MIN_PEER_PROTO_VERSION = 70030;
std::vector<CDarkSendEntry> myEntries;
std::vector<CDarkSendEntry> entries;
@ -2795,7 +2795,8 @@ public:
bool DoConcessusVote(int64 nBlockHeight);
int GetInputDarksendRounds(CTxIn in, int rounds=0);
bool SplitUpMoney(bool justCollateral=false);
int GetDenominations(std::vector<CTxOut> vout);
int GetDenominations(const std::vector<CTxOut>& vout);
int GetDenominationsByAmount(int64 nAmount);
};
void ConnectToDarkSendMasterNodeWinner();

View File

@ -313,6 +313,8 @@ void SendCoinsDialog::darkSendStatus()
}
}
if(!darkSendPool.sessionFoundMasternode) return;
int state = darkSendPool.GetState();
int entries = darkSendPool.GetEntriesCount();
int accepted = darkSendPool.GetLastEntryAccepted();

View File

@ -25,7 +25,7 @@ extern const std::string CLIENT_DATE;
// network protocol versioning
//
static const int PROTOCOL_VERSION = 70029;
static const int PROTOCOL_VERSION = 70030;
// intial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;