Skip to content

Commit

Permalink
Privatesend->PrivateSend Instantsend->InstantSend
Browse files Browse the repository at this point in the history
  • Loading branch information
Duality-CDOO committed Jun 20, 2018
1 parent 4616a34 commit 5340749
Show file tree
Hide file tree
Showing 34 changed files with 1,333 additions and 1,333 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ What is [Dynamic](https://duality.solutions/dynamic)?

[Dynamic(DYN)](https://duality.solutions/dynamic) lays the groundwork for offering BaaS(Blockchain as a Service) by hosting a multitude of second tier nodes called Dynodes. Rewards can be adjusted through the 'Fluid Protocol' created by [Duality](https://duality.solutions/) to adjust to a maturing market.

As a modern currency [Dynamic(DYN)](https://github.com/duality-solutions/dynamic) will be actively maintained to keep up with the latest market trends. [Dynamic(DYN)](https://github.com/duality-solutions/dynamic) features fast and Instantsend transactions at an affordable rate, also end-users that care for consumer privacy are able to anonymously transact using Privatesend.
As a modern currency [Dynamic(DYN)](https://github.com/duality-solutions/dynamic) will be actively maintained to keep up with the latest market trends. [Dynamic(DYN)](https://github.com/duality-solutions/dynamic) features fast and InstantSend transactions at an affordable rate, also end-users that care for consumer privacy are able to anonymously transact using PrivateSend.

[Dynamic(DYN)](https://github.com/duality-solutions/dynamic) utilises Dynodes which are the 2nd tier of security, processing InstantSend transactions and providing fungibility via PrivateSend.

Expand Down
6 changes: 3 additions & 3 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ What is Dynamic?

The Dynamic(DYN) blockchain exists in the Duality binary architecture as a DAO, whilst [Sequence(SEQ)](https://github.com/duality-solutions/sequence) is its real world interface. Dynamic uses peer-to-peer technology to operate securly with no central authority (decentralisation): managing transactions and issuing currency (DYN) are carried out collectively by the Dynamic network. Dynamic is the name of open source software which enables the use of the currency DYN.

Dynamic utilises Dynodes, Privatesend and InstantSend to provide anonymous and near instant transaction confirmations.
Dynamic utilises Dynodes, PrivateSend and InstantSend to provide anonymous and near instant transaction confirmations.

Dynamic implements Gavin Andresens signature cache optimisation from Bitcoin for significantly faster transaction validation.


**Dynode/Privatesend Network Information**
**Dynode/PrivateSend Network Information**
Ported Masternodes from Dash, rebranded as Dynodes.
Darksend ported and rebranded as Privatesend.
Darksend ported and rebranded as PrivateSend.
Utilisation of InstantSend for near-instant transactions.

**MainNet Parameters**
Expand Down
8 changes: 4 additions & 4 deletions dynamic-docs/protocol-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ When a new block is found on the network, a Dynode quorum will be determined and

### PSTX - "pstx"

CPrivatesendBroadcastTx
CPrivateSendBroadcastTx

Dynodes can broadcast subsidised transactions without fees for the sake of security in mixing. This is done via the PSTX message.

Expand All @@ -122,7 +122,7 @@ Mixing pool status update

### PSQUEUE - "psq"

CPrivatesendQueue
CPrivateSendQueue

Asks users to sign final mixing tx message.

Expand All @@ -145,7 +145,7 @@ Response to PSQ message which allows the user to join a mixing pool

### PSVIN - "psi"

CPrivatesendEntry
CPrivateSendEntry

When queue is ready user is expected to send his entry to start actual mixing

Expand Down Expand Up @@ -257,7 +257,7 @@ Dynode Verify

### PSFINALTX - "psf"

Privatesend Final Transaction
PrivateSend Final Transaction

### PSCOMPLETE - "psc"

Expand Down
2 changes: 1 addition & 1 deletion src/dynode.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct dynode_info_t
};

//
// The Dynode Class. For managing the Privatesend process. It contains the input of the 1000DYN, signature to prove
// The Dynode Class. For managing the PrivateSend process. It contains the input of the 1000DYN, signature to prove
// it's the one who own that ip address and code for calculating the payment election.
//
class CDynode : public dynode_info_t
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
nInstantSendDepth = GetArg("-instantsenddepth", DEFAULT_INSTANTSEND_DEPTH);
nInstantSendDepth = std::min(std::max(nInstantSendDepth, 0), 60);

//lite mode disables all Dynode and Privatesend related functionality
//lite mode disables all Dynode and PrivateSend related functionality
fLiteMode = GetBoolArg("-litemode", false);
if(fDynodeMode && fLiteMode){
return InitError("You can not start a Dynode in litemode");
Expand Down
4 changes: 2 additions & 2 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
}

if (!push && inv.type == MSG_PSTX) {
CPrivatesendBroadcastTx pstx = CPrivateSend::GetPSTX(inv.hash);
CPrivateSendBroadcastTx pstx = CPrivateSend::GetPSTX(inv.hash);
if(pstx) {
connman.PushMessage(pfrom, NetMsgType::PSTX, pstx);
push = true;
Expand Down Expand Up @@ -1580,7 +1580,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
vector<uint256> vEraseQueue;
CTransaction tx;
CTxLockRequest txLockRequest;
CPrivatesendBroadcastTx pstx;
CPrivateSendBroadcastTx pstx;
int nInvType = MSG_TX;

// Read data and assign inv type
Expand Down
12 changes: 6 additions & 6 deletions src/privatesend-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ void CPrivateSendClient::ProcessMessage(CNode* pfrom, std::string& strCommand, C
return;
}

CPrivatesendQueue psq;
CPrivateSendQueue psq;
vRecv >> psq;

// process every psq only once
BOOST_FOREACH(CPrivatesendQueue q, vecPrivatesendQueue) {
BOOST_FOREACH(CPrivateSendQueue q, vecPrivateSendQueue) {
if(q == psq) {
// LogPrint("privatesend", "PSQUEUE -- %s seen\n", psq.ToString());
return;
Expand Down Expand Up @@ -72,7 +72,7 @@ void CPrivateSendClient::ProcessMessage(CNode* pfrom, std::string& strCommand, C
SubmitDenominate(connman);
}
} else {
BOOST_FOREACH(CPrivatesendQueue q, vecPrivatesendQueue) {
BOOST_FOREACH(CPrivateSendQueue q, vecPrivateSendQueue) {
if(q.vin == psq.vin) {
// no way same dn can send another "not yet ready" psq this soon
LogPrint("privatesend", "PSQUEUE -- Dynode %s is sending WAY too many psq messages\n", infoDn.addr.ToString());
Expand All @@ -94,7 +94,7 @@ void CPrivateSendClient::ProcessMessage(CNode* pfrom, std::string& strCommand, C
if(infoMixingDynode.fInfoValid && infoMixingDynode.vin.prevout == psq.vin.prevout) {
psq.fTried = true;
}
vecPrivatesendQueue.push_back(psq);
vecPrivateSendQueue.push_back(psq);
psq.Relay(connman);
}

Expand Down Expand Up @@ -823,7 +823,7 @@ bool CPrivateSendClient::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CCon
{
std::vector<CAmount> vecStandardDenoms = CPrivateSend::GetStandardDenominations();
// Look through the queues and see if anything matches
BOOST_FOREACH(CPrivatesendQueue& psq, vecPrivatesendQueue) {
BOOST_FOREACH(CPrivateSendQueue& psq, vecPrivateSendQueue) {
// only try each queue once
if(psq.fTried) continue;
psq.fTried = true;
Expand All @@ -846,7 +846,7 @@ bool CPrivateSendClient::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CCon
}

// mixing rate limit i.e. nLastPsq check should already pass in PSQUEUE ProcessMessage
// in order for psq to get into vecPrivatesendQueue, so we should be safe to mix already,
// in order for psq to get into vecPrivateSendQueue, so we should be safe to mix already,
// no need for additional verification here

LogPrint("privatesend", "CPrivateSendClient::JoinExistingQueue -- found valid queue: %s\n", psq.ToString());
Expand Down
16 changes: 8 additions & 8 deletions src/privatesend-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, std::string& strCommand, C
return;
}

CPrivatesendQueue psq;
CPrivateSendQueue psq;
vRecv >> psq;

// process every psq only once
BOOST_FOREACH(CPrivatesendQueue q, vecPrivatesendQueue) {
BOOST_FOREACH(CPrivateSendQueue q, vecPrivateSendQueue) {
if(q == psq) {
// LogPrint("privatesend", "PSQUEUE -- %s seen\n", psq.ToString());
return;
Expand All @@ -107,7 +107,7 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, std::string& strCommand, C
}

if(!psq.fReady) {
BOOST_FOREACH(CPrivatesendQueue q, vecPrivatesendQueue) {
BOOST_FOREACH(CPrivateSendQueue q, vecPrivateSendQueue) {
if(q.vin == psq.vin) {
// no way same dn can send another "not yet ready" psq this soon
LogPrint("privatesend", "PSQUEUE -- Dynode %s is sending WAY too many psq messages\n", dnInfo.addr.ToString());
Expand All @@ -125,7 +125,7 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, std::string& strCommand, C
dnodeman.AllowMixing(psq.vin.prevout);

LogPrint("privatesend", "PSQUEUE -- new PrivateSend queue (%s) from dynode %s\n", psq.ToString(), dnInfo.addr.ToString());
vecPrivatesendQueue.push_back(psq);
vecPrivateSendQueue.push_back(psq);
psq.Relay(connman);
}

Expand Down Expand Up @@ -359,7 +359,7 @@ void CPrivateSendServer::CommitFinalTransaction(CConnman& connman)

// create and sign dynode pstx transaction
if(!CPrivateSend::GetPSTX(hashTx)) {
CPrivatesendBroadcastTx pstxNew(finalTransaction, activeDynode.outpoint, GetAdjustedTime());
CPrivateSendBroadcastTx pstxNew(finalTransaction, activeDynode.outpoint, GetAdjustedTime());
pstxNew.Sign();
CPrivateSend::AddPSTX(pstxNew);
}
Expand Down Expand Up @@ -526,7 +526,7 @@ void CPrivateSendServer::CheckForCompleteQueue(CConnman& connman)
if(nState == POOL_STATE_QUEUE && IsSessionReady()) {
SetState(POOL_STATE_ACCEPTING_ENTRIES);

CPrivatesendQueue psq(nSessionDenom, activeDynode.outpoint, GetAdjustedTime(), true);
CPrivateSendQueue psq(nSessionDenom, activeDynode.outpoint, GetAdjustedTime(), true);
LogPrint("privatesend", "CPrivateSendServer::CheckForCompleteQueue -- queue is ready, signing and relaying (%s)\n", psq.ToString());
psq.Sign();
psq.Relay(connman);
Expand Down Expand Up @@ -732,11 +732,11 @@ bool CPrivateSendServer::CreateNewSession(int nDenom, CTransaction txCollateral,

if(!fUnitTest) {
//broadcast that I'm accepting entries, only if it's the first entry through
CPrivatesendQueue psq(nDenom, activeDynode.outpoint, GetAdjustedTime(), false);
CPrivateSendQueue psq(nDenom, activeDynode.outpoint, GetAdjustedTime(), false);
LogPrint("privatesend", "CPrivateSendServer::CreateNewSession -- signing and relaying new queue: %s\n", psq.ToString());
psq.Sign();
psq.Relay(connman);
vecPrivatesendQueue.push_back(psq);
vecPrivateSendQueue.push_back(psq);
}

vecSessionCollaterals.push_back(txCollateral);
Expand Down
36 changes: 18 additions & 18 deletions src/privatesend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,34 @@ bool CPrivateSendEntry::AddScriptSig(const CTxIn& txin)
return false;
}

bool CPrivatesendQueue::Sign()
bool CPrivateSendQueue::Sign()
{
if(!fDynodeMode) return false;

std::string strMessage = vin.ToString() + boost::lexical_cast<std::string>(nDenom) + boost::lexical_cast<std::string>(nTime) + boost::lexical_cast<std::string>(fReady);

if(!CMessageSigner::SignMessage(strMessage, vchSig, activeDynode.keyDynode)) {
LogPrintf("CPrivatesendQueue::Sign -- SignMessage() failed, %s\n", ToString());
LogPrintf("CPrivateSendQueue::Sign -- SignMessage() failed, %s\n", ToString());
return false;
}

return CheckSignature(activeDynode.pubKeyDynode);
}

bool CPrivatesendQueue::CheckSignature(const CPubKey& pubKeyDynode)
bool CPrivateSendQueue::CheckSignature(const CPubKey& pubKeyDynode)
{
std::string strMessage = vin.ToString() + boost::lexical_cast<std::string>(nDenom) + boost::lexical_cast<std::string>(nTime) + boost::lexical_cast<std::string>(fReady);
std::string strError = "";

if(!CMessageSigner::VerifyMessage(pubKeyDynode, vchSig, strMessage, strError)) {
LogPrintf("CPrivatesendQueue::CheckSignature -- Got bad Dynode queue signature: %s; error: %s\n", ToString(), strError);
LogPrintf("CPrivateSendQueue::CheckSignature -- Got bad Dynode queue signature: %s; error: %s\n", ToString(), strError);
return false;
}

return true;
}

bool CPrivatesendQueue::Relay(CConnman& connman)
bool CPrivateSendQueue::Relay(CConnman& connman)
{
std::vector<CNode*> vNodesCopy = connman.CopyNodeVector();
BOOST_FOREACH(CNode* pnode, vNodesCopy)
Expand All @@ -75,34 +75,34 @@ bool CPrivatesendQueue::Relay(CConnman& connman)
return true;
}

bool CPrivatesendBroadcastTx::Sign()
bool CPrivateSendBroadcastTx::Sign()
{
if(!fDynodeMode) return false;

std::string strMessage = tx.GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);

if(!CMessageSigner::SignMessage(strMessage, vchSig, activeDynode.keyDynode)) {
LogPrintf("CPrivatesendBroadcastTx::Sign -- SignMessage() failed\n");
LogPrintf("CPrivateSendBroadcastTx::Sign -- SignMessage() failed\n");
return false;
}

return CheckSignature(activeDynode.pubKeyDynode);
}

bool CPrivatesendBroadcastTx::CheckSignature(const CPubKey& pubKeyDynode)
bool CPrivateSendBroadcastTx::CheckSignature(const CPubKey& pubKeyDynode)
{
std::string strMessage = tx.GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);
std::string strError = "";

if(!CMessageSigner::VerifyMessage(pubKeyDynode, vchSig, strMessage, strError)) {
LogPrintf("CPrivatesendBroadcastTx::CheckSignature -- Got bad pstx signature, error: %s\n", strError);
LogPrintf("CPrivateSendBroadcastTx::CheckSignature -- Got bad pstx signature, error: %s\n", strError);
return false;
}

return true;
}

bool CPrivatesendBroadcastTx::IsExpired(int nHeight)
bool CPrivateSendBroadcastTx::IsExpired(int nHeight)
{
// expire confirmed PSTXes after ~1h since confirmation
return (nConfirmedHeight != -1) && (nHeight - nConfirmedHeight > 24);
Expand All @@ -126,11 +126,11 @@ void CPrivateSendBase::CheckQueue()
if(!lockPS) return; // it's ok to fail here, we run this quite frequently

// check mixing queue objects for timeouts
std::vector<CPrivatesendQueue>::iterator it = vecPrivatesendQueue.begin();
while(it != vecPrivatesendQueue.end()) {
std::vector<CPrivateSendQueue>::iterator it = vecPrivateSendQueue.begin();
while(it != vecPrivateSendQueue.end()) {
if((*it).IsExpired()) {
LogPrint("privatesend", "CPrivateSendBase::%s -- Removing expired queue (%s)\n", __func__, (*it).ToString());
it = vecPrivatesendQueue.erase(it);
it = vecPrivateSendQueue.erase(it);
} else ++it;
}
}
Expand All @@ -150,7 +150,7 @@ std::string CPrivateSendBase::GetStateString() const

// Definitions for static data members
std::vector<CAmount> CPrivateSend::vecStandardDenominations;
std::map<uint256, CPrivatesendBroadcastTx> CPrivateSend::mapPSTX;
std::map<uint256, CPrivateSendBroadcastTx> CPrivateSend::mapPSTX;
CCriticalSection CPrivateSend::cs_mappstx;

void CPrivateSend::InitStandardDenominations()
Expand Down Expand Up @@ -378,23 +378,23 @@ std::string CPrivateSend::GetMessageByID(PoolMessage nMessageID)
}
}

void CPrivateSend::AddPSTX(const CPrivatesendBroadcastTx& pstx)
void CPrivateSend::AddPSTX(const CPrivateSendBroadcastTx& pstx)
{
LOCK(cs_mappstx);
mapPSTX.insert(std::make_pair(pstx.tx.GetHash(), pstx));
}

CPrivatesendBroadcastTx CPrivateSend::GetPSTX(const uint256& hash)
CPrivateSendBroadcastTx CPrivateSend::GetPSTX(const uint256& hash)
{
LOCK(cs_mappstx);
auto it = mapPSTX.find(hash);
return (it == mapPSTX.end()) ? CPrivatesendBroadcastTx() : it->second;
return (it == mapPSTX.end()) ? CPrivateSendBroadcastTx() : it->second;
}

void CPrivateSend::CheckPSTXes(int nHeight)
{
LOCK(cs_mappstx);
std::map<uint256, CPrivatesendBroadcastTx>::iterator it = mapPSTX.begin();
std::map<uint256, CPrivateSendBroadcastTx>::iterator it = mapPSTX.begin();
while(it != mapPSTX.end()) {
if (it->second.IsExpired(nHeight)) {
mapPSTX.erase(it++);
Expand Down
Loading

0 comments on commit 5340749

Please sign in to comment.