Skip to content

Commit

Permalink
Rename IXLOCK to ISLOCK and InstantX to InstantSend
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Mar 7, 2019
1 parent f5dcb00 commit 2299ee2
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 198 deletions.
4 changes: 2 additions & 2 deletions src/llmq/quorums_chainlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void CChainLocksHandler::TrySignChainTip()
}
}

if (txAge < WAIT_FOR_IXLOCK_TIMEOUT && !quorumInstantSendManager->IsLocked(txid)) {
if (txAge < WAIT_FOR_ISLOCK_TIMEOUT && !quorumInstantSendManager->IsLocked(txid)) {
LogPrintf("CChainLocksHandler::%s -- not signing block %s due to TX %s not being ixlocked and not old enough. age=%d\n", __func__,
pindexWalk->GetBlockHash().ToString(), txid.ToString(), txAge);
return;
Expand Down Expand Up @@ -396,7 +396,7 @@ bool CChainLocksHandler::IsTxSafeForMining(const uint256& txid)
}
}

if (txAge < WAIT_FOR_IXLOCK_TIMEOUT && !quorumInstantSendManager->IsLocked(txid)) {
if (txAge < WAIT_FOR_ISLOCK_TIMEOUT && !quorumInstantSendManager->IsLocked(txid)) {
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/quorums_chainlocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CChainLocksHandler : public CRecoveredSigsListener
static const int64_t CLEANUP_SEEN_TIMEOUT = 24 * 60 * 60 * 1000;

// how long to wait for ixlocks until we consider a block with non-ixlocked TXs to be safe to sign
static const int64_t WAIT_FOR_IXLOCK_TIMEOUT = 10 * 60;
static const int64_t WAIT_FOR_ISLOCK_TIMEOUT = 10 * 60;

private:
CScheduler* scheduler;
Expand Down
302 changes: 151 additions & 151 deletions src/llmq/quorums_instantsend.cpp

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions src/llmq/quorums_instantsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef DASH_QUORUMS_INSTANTX_H
#define DASH_QUORUMS_INSTANTX_H
#ifndef DASH_QUORUMS_INSTANTSEND_H
#define DASH_QUORUMS_INSTANTSEND_H

#include "quorums_signing.h"

Expand All @@ -18,7 +18,7 @@ class CScheduler;
namespace llmq
{

class CInstantXLock
class CInstantSendLock
{
public:
std::vector<COutPoint> inputs;
Expand All @@ -39,14 +39,14 @@ class CInstantXLock
uint256 GetRequestId() const;
};

class CInstantXLockInfo
class CInstantSendLockInfo
{
public:
// might be nullptr when ixlock is received before the TX itself
// might be nullptr when islock is received before the TX itself
CTransactionRef tx;
CInstantXLock ixlock;
CInstantSendLock islock;
// only valid when recovered sig was received
uint256 ixlockHash;
uint256 islockHash;
// time when it was created/received
int64_t time;

Expand All @@ -68,27 +68,27 @@ class CInstantSendManager : public CRecoveredSigsListener
std::unordered_map<uint256, uint256, StaticSaltedHasher> inputVotes;

/**
* These are the ixlocks that are currently in the middle of being created. Entries are created when we observed
* recovered signatures for all inputs of a TX. At the same time, we initiate signing of our sigshare for the ixlock.
* When the recovered sig for the ixlock later arrives, we can finish the ixlock and propagate it.
* These are the islocks that are currently in the middle of being created. Entries are created when we observed
* recovered signatures for all inputs of a TX. At the same time, we initiate signing of our sigshare for the islock.
* When the recovered sig for the islock later arrives, we can finish the islock and propagate it.
*/
std::unordered_map<uint256, CInstantXLockInfo, StaticSaltedHasher> creatingInstantXLocks;
// maps from txid to the in-progress ixlock
std::unordered_map<uint256, CInstantXLockInfo*, StaticSaltedHasher> txToCreatingInstantXLocks;
std::unordered_map<uint256, CInstantSendLockInfo, StaticSaltedHasher> creatingInstantSendLocks;
// maps from txid to the in-progress islock
std::unordered_map<uint256, CInstantSendLockInfo*, StaticSaltedHasher> txToCreatingInstantSendLocks;

/**
* These are the final ixlocks, indexed by their own hash. The other maps are used to get from TXs, inputs and blocks
* to ixlocks.
* These are the final islocks, indexed by their own hash. The other maps are used to get from TXs, inputs and blocks
* to islocks.
*/
std::unordered_map<uint256, CInstantXLockInfo, StaticSaltedHasher> finalInstantXLocks;
std::unordered_map<uint256, CInstantXLockInfo*, StaticSaltedHasher> txToInstantXLock;
std::unordered_map<COutPoint, CInstantXLockInfo*, SaltedOutpointHasher> inputToInstantXLock;
std::unordered_multimap<uint256, CInstantXLockInfo*, StaticSaltedHasher> blockToInstantXLocks;
std::unordered_map<uint256, CInstantSendLockInfo, StaticSaltedHasher> finalInstantSendLocks;
std::unordered_map<uint256, CInstantSendLockInfo*, StaticSaltedHasher> txToInstantSendLock;
std::unordered_map<COutPoint, CInstantSendLockInfo*, SaltedOutpointHasher> inputToInstantSendLock;
std::unordered_multimap<uint256, CInstantSendLockInfo*, StaticSaltedHasher> blockToInstantSendLocks;

const CBlockIndex* pindexLastChainLock{nullptr};

// Incoming and not verified yet
std::unordered_map<uint256, std::pair<NodeId, CInstantXLock>> pendingInstantXLocks;
std::unordered_map<uint256, std::pair<NodeId, CInstantSendLock>> pendingInstantSendLocks;
bool hasScheduledProcessPending{false};

public:
Expand All @@ -108,27 +108,27 @@ class CInstantSendManager : public CRecoveredSigsListener

virtual void HandleNewRecoveredSig(const CRecoveredSig& recoveredSig);
void HandleNewInputLockRecoveredSig(const CRecoveredSig& recoveredSig, const uint256& txid);
void HandleNewInstantXLockRecoveredSig(const CRecoveredSig& recoveredSig);
void HandleNewInstantSendLockRecoveredSig(const CRecoveredSig& recoveredSig);

void TrySignInstantXLock(const CTransaction& tx);
void TrySignInstantSendLock(const CTransaction& tx);

void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);
void ProcessMessageInstantXLock(CNode* pfrom, const CInstantXLock& ixlock, CConnman& connman);
bool PreVerifyInstantXLock(NodeId nodeId, const CInstantXLock& ixlock, bool& retBan);
void ProcessPendingInstantXLocks();
void ProcessInstantXLock(NodeId from, const uint256& hash, const CInstantXLock& ixlock);
void ProcessMessageInstantSendLock(CNode* pfrom, const CInstantSendLock& islock, CConnman& connman);
bool PreVerifyInstantSendLock(NodeId nodeId, const CInstantSendLock& islock, bool& retBan);
void ProcessPendingInstantSendLocks();
void ProcessInstantSendLock(NodeId from, const uint256& hash, const CInstantSendLock& islock);
void UpdateWalletTransaction(const uint256& txid);

void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock);
void NotifyChainLock(const CBlockIndex* pindex);
void UpdateIxLockMinedBlock(CInstantXLockInfo* ixlockInfo, const CBlockIndex* pindex);
void RemoveFinalIxLock(const uint256& hash);
void UpdateISLockMinedBlock(CInstantSendLockInfo* islockInfo, const CBlockIndex* pindex);
void RemoveFinalISLock(const uint256& hash);

void RemoveMempoolConflictsForLock(const uint256& hash, const CInstantXLock& ixlock);
void RemoveMempoolConflictsForLock(const uint256& hash, const CInstantSendLock& islock);
void RetryLockMempoolTxs(const uint256& lockedParentTx);

bool AlreadyHave(const CInv& inv);
bool GetInstantXLockByHash(const uint256& hash, CInstantXLock& ret);
bool GetInstantSendLockByHash(const uint256& hash, CInstantSendLock& ret);
};

extern CInstantSendManager* quorumInstantSendManager;
Expand All @@ -144,4 +144,4 @@ bool IsInstantSendEnabled();

}

#endif//DASH_QUORUMS_INSTANTX_H
#endif//DASH_QUORUMS_INSTANTSEND_H
2 changes: 1 addition & 1 deletion src/llmq/quorums_signing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void CSigningManager::ProcessRecoveredSig(NodeId nodeId, const CRecoveredSig& re
} else {
// Looks like we're trying to process a recSig that is already known. This might happen if the same
// recSig comes in through regular QRECSIG messages and at the same time through some other message
// which allowed to reconstruct a recSig (e.g. IXLOCK). In this case, just bail out.
// which allowed to reconstruct a recSig (e.g. ISLOCK). In this case, just bail out.
}
return;
} else {
Expand Down
12 changes: 6 additions & 6 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
return llmq::quorumSigningManager->AlreadyHave(inv);
case MSG_CLSIG:
return llmq::chainLocksHandler->AlreadyHave(inv);
case MSG_IXLOCK:
case MSG_ISLOCK:
return llmq::quorumInstantSendManager->AlreadyHave(inv);
}

Expand Down Expand Up @@ -1299,10 +1299,10 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
}
}

if (!push && (inv.type == MSG_IXLOCK)) {
llmq::CInstantXLock o;
if (llmq::quorumInstantSendManager->GetInstantXLockByHash(inv.hash, o)) {
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::IXLOCK, o));
if (!push && (inv.type == MSG_ISLOCK)) {
llmq::CInstantSendLock o;
if (llmq::quorumInstantSendManager->GetInstantSendLockByHash(inv.hash, o)) {
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::ISLOCK, o));
push = true;
}
}
Expand Down Expand Up @@ -1788,7 +1788,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
case MSG_CLSIG:
doubleRequestDelay = 5 * 1000000;
break;
case MSG_IXLOCK:
case MSG_ISLOCK:
doubleRequestDelay = 5 * 1000000;
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const char *QGETSIGSHARES="qgetsigs";
const char *QBSIGSHARES="qbsigs";
const char *QSIGREC="qsigrec";
const char *CLSIG="clsig";
const char *IXLOCK="ixlock";
const char *ISLOCK="islock";
};

static const char* ppszTypeName[] =
Expand Down Expand Up @@ -108,7 +108,7 @@ static const char* ppszTypeName[] =
NetMsgType::QDEBUGSTATUS,
NetMsgType::QSIGREC,
NetMsgType::CLSIG,
NetMsgType::IXLOCK,
NetMsgType::ISLOCK,
};

/** All known message types. Keep this in the same order as the list of
Expand Down Expand Up @@ -174,7 +174,7 @@ const static std::string allNetMessageTypes[] = {
NetMsgType::QBSIGSHARES,
NetMsgType::QSIGREC,
NetMsgType::CLSIG,
NetMsgType::IXLOCK,
NetMsgType::ISLOCK,
};
const static std::vector<std::string> allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes));

Expand Down
4 changes: 2 additions & 2 deletions src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ extern const char *QGETSIGSHARES;
extern const char *QBSIGSHARES;
extern const char *QSIGREC;
extern const char *CLSIG;
extern const char *IXLOCK;
extern const char *ISLOCK;
};

/* Get a vector of all valid message types (see above) */
Expand Down Expand Up @@ -380,7 +380,7 @@ enum GetDataMsg {
MSG_QUORUM_DEBUG_STATUS = 27,
MSG_QUORUM_RECOVERED_SIG = 28,
MSG_CLSIG = 29,
MSG_IXLOCK = 30,
MSG_ISLOCK = 30,
};

/** inv message data */
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3346,7 +3346,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
int& nChangePosInOut, std::string& strFailReason, const CCoinControl* coinControl, bool sign, AvailableCoinsType nCoinType, bool fUseInstantSend, int nExtraPayloadSize)
{
if (!llmq::IsOldInstantSendEnabled()) {
// The new system does not require special handling for InstantSend as this is all done in CInstantXManager.
// The new system does not require special handling for InstantSend as this is all done in CInstantSendManager.
// There is also no need for an extra fee anymore.
fUseInstantSend = false;
}
Expand Down

0 comments on commit 2299ee2

Please sign in to comment.