mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Comment updates - InstantSend (#2062)
* [Comment] - Minor Instantx comment updates and additions * [Comment] - Update to doxygen recognised format - Capitalisation changes * [Comment] - Add some minor InstantSend comments
This commit is contained in:
parent
febdc2116c
commit
ef85d5144d
@ -39,10 +39,10 @@ CInstantSend instantsend;
|
||||
|
||||
// Transaction Locks
|
||||
//
|
||||
// step 1) Some node announces intention to lock transaction inputs via "txlreg" message
|
||||
// step 2) Top COutPointLock::SIGNATURES_TOTAL masternodes per each spent outpoint push "txvote" message
|
||||
// step 3) Once there are COutPointLock::SIGNATURES_REQUIRED valid "txvote" messages per each spent outpoint
|
||||
// for a corresponding "txlreg" message, all outpoints from that tx are treated as locked
|
||||
// step 1) Some node announces intention to lock transaction inputs via "txlockrequest" message (ix)
|
||||
// step 2) Top COutPointLock::SIGNATURES_TOTAL masternodes per each spent outpoint push "txlockvote" message (txlvote)
|
||||
// step 3) Once there are COutPointLock::SIGNATURES_REQUIRED valid "txlockvote" messages (txlvote) per each spent outpoint
|
||||
// for a corresponding "txlockrequest" message (ix), all outpoints from that tx are treated as locked
|
||||
|
||||
//
|
||||
// CInstantSend
|
||||
|
@ -26,23 +26,30 @@ extern CInstantSend instantsend;
|
||||
(1000/2900.0)**5 = 0.004875397277841433
|
||||
*/
|
||||
|
||||
// The INSTANTSEND_DEPTH is the "pseudo block depth" level assigned to locked
|
||||
// txs to indicate the degree of confidence in their eventual confirmation and
|
||||
// inability to be double-spent (adjustable via command line argument)
|
||||
static const int MIN_INSTANTSEND_DEPTH = 0;
|
||||
static const int MAX_INSTANTSEND_DEPTH = 60;
|
||||
/// Default number of "pseudo-confirmations" for an InstantSend tx
|
||||
static const int DEFAULT_INSTANTSEND_DEPTH = 5;
|
||||
|
||||
static const int MIN_INSTANTSEND_PROTO_VERSION = 70208;
|
||||
|
||||
// For how long we are going to accept votes/locks
|
||||
// after we saw the first one for a specific transaction
|
||||
/// For how long we are going to accept votes/locks
|
||||
/// after we saw the first one for a specific transaction
|
||||
static const int INSTANTSEND_LOCK_TIMEOUT_SECONDS = 15;
|
||||
// For how long we are going to keep invalid votes and votes for failed lock attempts,
|
||||
// must be greater than INSTANTSEND_LOCK_TIMEOUT_SECONDS
|
||||
/// For how long we are going to keep invalid votes and votes for failed lock attempts,
|
||||
/// must be greater than INSTANTSEND_LOCK_TIMEOUT_SECONDS
|
||||
static const int INSTANTSEND_FAILED_TIMEOUT_SECONDS = 60;
|
||||
|
||||
extern bool fEnableInstantSend;
|
||||
extern int nInstantSendDepth;
|
||||
extern int nCompleteTXLocks;
|
||||
|
||||
/**
|
||||
* Manages InstantSend. Processes lock requests, candidates, and votes.
|
||||
*/
|
||||
class CInstantSend
|
||||
{
|
||||
private:
|
||||
@ -50,24 +57,24 @@ private:
|
||||
int nCachedBlockHeight;
|
||||
|
||||
// maps for AlreadyHave
|
||||
std::map<uint256, CTxLockRequest> mapLockRequestAccepted; // tx hash - tx
|
||||
std::map<uint256, CTxLockRequest> mapLockRequestRejected; // tx hash - tx
|
||||
std::map<uint256, CTxLockVote> mapTxLockVotes; // vote hash - vote
|
||||
std::map<uint256, CTxLockVote> mapTxLockVotesOrphan; // vote hash - vote
|
||||
std::map<uint256, CTxLockRequest> mapLockRequestAccepted; ///< Tx hash - Tx
|
||||
std::map<uint256, CTxLockRequest> mapLockRequestRejected; ///< Tx hash - Tx
|
||||
std::map<uint256, CTxLockVote> mapTxLockVotes; ///< Vote hash - Vote
|
||||
std::map<uint256, CTxLockVote> mapTxLockVotesOrphan; ///< Vote hash - Vote
|
||||
|
||||
std::map<uint256, CTxLockCandidate> mapTxLockCandidates; // tx hash - lock candidate
|
||||
std::map<uint256, CTxLockCandidate> mapTxLockCandidates; ///< Tx hash - Lock candidate
|
||||
|
||||
std::map<COutPoint, std::set<uint256> > mapVotedOutpoints; // utxo - tx hash set
|
||||
std::map<COutPoint, uint256> mapLockedOutpoints; // utxo - tx hash
|
||||
std::map<COutPoint, std::set<uint256> > mapVotedOutpoints; ///< UTXO - Tx hash set
|
||||
std::map<COutPoint, uint256> mapLockedOutpoints; ///< UTXO - Tx hash
|
||||
|
||||
//track masternodes who voted with no txreq (for DOS protection)
|
||||
std::map<COutPoint, int64_t> mapMasternodeOrphanVotes; // mn outpoint - time
|
||||
/// Track masternodes who voted with no txlockrequest (for DOS protection)
|
||||
std::map<COutPoint, int64_t> mapMasternodeOrphanVotes; ///< MN outpoint - Time
|
||||
|
||||
bool CreateTxLockCandidate(const CTxLockRequest& txLockRequest);
|
||||
void CreateEmptyTxLockCandidate(const uint256& txHash);
|
||||
void Vote(CTxLockCandidate& txLockCandidate, CConnman& connman);
|
||||
|
||||
//process consensus vote message
|
||||
/// Process consensus vote message
|
||||
bool ProcessNewTxLockVote(CNode* pfrom, const CTxLockVote& vote, CConnman& connman);
|
||||
|
||||
void UpdateVotedOutpoints(const CTxLockVote& vote, CTxLockCandidate& txLockCandidate);
|
||||
@ -77,7 +84,7 @@ private:
|
||||
|
||||
void TryToFinalizeLockCandidate(const CTxLockCandidate& txLockCandidate);
|
||||
void LockTransactionInputs(const CTxLockCandidate& txLockCandidate);
|
||||
//update UI and notify external script if any
|
||||
/// Update UI and notify external script if any
|
||||
void UpdateLockedTransaction(const CTxLockCandidate& txLockCandidate);
|
||||
bool ResolveConflicts(const CTxLockCandidate& txLockCandidate);
|
||||
|
||||
@ -102,16 +109,16 @@ public:
|
||||
|
||||
bool GetLockedOutPointTxHash(const COutPoint& outpoint, uint256& hashRet);
|
||||
|
||||
// verify if transaction is currently locked
|
||||
/// Verify if transaction is currently locked
|
||||
bool IsLockedInstantSendTransaction(const uint256& txHash);
|
||||
// get the actual number of accepted lock signatures
|
||||
/// Get the actual number of accepted lock signatures
|
||||
int GetTransactionLockSignatures(const uint256& txHash);
|
||||
// get instantsend confirmations (only)
|
||||
/// Get instantsend confirmations (only)
|
||||
int GetConfirmations(const uint256 &nTXHash);
|
||||
|
||||
// remove expired entries from maps
|
||||
/// Remove expired entries from maps
|
||||
void CheckAndRemove();
|
||||
// verify if transaction lock timed out
|
||||
/// Verify if transaction lock timed out
|
||||
bool IsTxLockCandidateTimedOut(const uint256& txHash);
|
||||
|
||||
void Relay(const uint256& txHash, CConnman& connman);
|
||||
@ -122,12 +129,17 @@ public:
|
||||
std::string ToString();
|
||||
};
|
||||
|
||||
/**
|
||||
* An InstantSend transaction lock request.
|
||||
*/
|
||||
class CTxLockRequest
|
||||
{
|
||||
private:
|
||||
static const CAmount MIN_FEE = 0.0001 * COIN;
|
||||
|
||||
public:
|
||||
/// Warn for a large number of inputs to an IS tx - fees could be substantial
|
||||
/// and the number txlvote responses requested large (10 * # of inputs)
|
||||
static const int WARN_MANY_INPUTS = 100;
|
||||
|
||||
CTransactionRef tx;
|
||||
@ -170,6 +182,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* An InstantSend transaction lock vote. Sent by a masternode in response to a
|
||||
* transaction lock request (ix message) to indicate the transaction input can
|
||||
* be locked. Contains the proposed transaction's hash and the outpoint being
|
||||
* locked along with the masternodes outpoint and signature.
|
||||
* @see CTxLockRequest
|
||||
*/
|
||||
class CTxLockVote
|
||||
{
|
||||
private:
|
||||
@ -178,7 +197,7 @@ private:
|
||||
COutPoint outpointMasternode;
|
||||
std::vector<unsigned char> vchMasternodeSignature;
|
||||
// local memory only
|
||||
int nConfirmedHeight; // when corresponding tx is 0-confirmed or conflicted, nConfirmedHeight is -1
|
||||
int nConfirmedHeight; ///< When corresponding tx is 0-confirmed or conflicted, nConfirmedHeight is -1
|
||||
int64_t nTimeCreated;
|
||||
|
||||
public:
|
||||
@ -231,11 +250,14 @@ public:
|
||||
void Relay(CConnman& connman) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* An InstantSend OutpointLock.
|
||||
*/
|
||||
class COutPointLock
|
||||
{
|
||||
private:
|
||||
COutPoint outpoint; // utxo
|
||||
std::map<COutPoint, CTxLockVote> mapMasternodeVotes; // masternode outpoint - vote
|
||||
COutPoint outpoint; ///< UTXO
|
||||
std::map<COutPoint, CTxLockVote> mapMasternodeVotes; ///< Masternode outpoint - vote
|
||||
bool fAttacked = false;
|
||||
|
||||
public:
|
||||
@ -259,10 +281,13 @@ public:
|
||||
void Relay(CConnman& connman) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* An InstantSend transaction lock candidate.
|
||||
*/
|
||||
class CTxLockCandidate
|
||||
{
|
||||
private:
|
||||
int nConfirmedHeight; // when corresponding tx is 0-confirmed or conflicted, nConfirmedHeight is -1
|
||||
int nConfirmedHeight; ///<When corresponding tx is 0-confirmed or conflicted, nConfirmedHeight is -1
|
||||
int64_t nTimeCreated;
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user