Skip to content

Commit 8c91a8b

Browse files
docs: introduce doxygen comments for InstantSend (dashpay#4279)
* add comments Signed-off-by: Pasta <[email protected]> * Add doxygen comments for IS database handler Signed-off-by: Pasta <[email protected]> * Apply suggestions from code review Co-authored-by: UdjinM6 <[email protected]> * Apply suggestions from code review Co-authored-by: UdjinM6 <[email protected]> Co-authored-by: UdjinM6 <[email protected]>
1 parent 2b56004 commit 8c91a8b

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

src/llmq/quorums_instantsend.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,93 @@ class CInstantSendDb
5858

5959
void Upgrade();
6060

61+
/**
62+
* This method is called when an InstantSend Lock is processed and adds the lock to the database
63+
* @param hash The hash of the InstantSend Lock
64+
* @param islock The InstantSend Lock object itself
65+
*/
6166
void WriteNewInstantSendLock(const uint256& hash, const CInstantSendLock& islock);
67+
/**
68+
* This method removes a InstantSend Lock from the database and is called when a tx with an IS lock is confirmed and Chainlocked
69+
* @param batch Object used to batch many calls together
70+
* @param hash The hash of the InstantSend Lock
71+
* @param islock The InstantSend Lock object itself
72+
* @param keep_cache Should we still keep corresponding entries in the cache or not
73+
*/
6274
void RemoveInstantSendLock(CDBBatch& batch, const uint256& hash, CInstantSendLockPtr islock, bool keep_cache = true);
6375

76+
/**
77+
* This method updates a DB entry for an InstantSend Lock from being not included in a block to being included in a block
78+
* @param hash The hash of the InstantSend Lock
79+
* @param nHeight The height that the transaction was included at
80+
*/
6481
void WriteInstantSendLockMined(const uint256& hash, int nHeight);
82+
/**
83+
* Marks an InstantSend Lock as archived.
84+
* @param batch Object used to batch many calls together
85+
* @param hash The hash of the InstantSend Lock
86+
* @param nHeight The height that the transaction was included at
87+
*/
6588
static void WriteInstantSendLockArchived(CDBBatch& batch, const uint256& hash, int nHeight);
89+
/**
90+
* Archives and deletes all IS Locks which were mined into a block before nUntilHeight
91+
* @param nUntilHeight Removes all IS Locks confirmed up until nUntilHeight
92+
* @return returns an unordered_map of the hash of the IS Locks and a pointer object to the IS Locks for all IS Locks which were removed
93+
*/
6694
std::unordered_map<uint256, CInstantSendLockPtr> RemoveConfirmedInstantSendLocks(int nUntilHeight);
95+
/**
96+
* Removes IS Locks from the archive if the tx was confirmed 100 blocks before nUntilHeight
97+
* @param nUntilHeight the height from which to base the remove of archive IS Locks
98+
*/
6799
void RemoveArchivedInstantSendLocks(int nUntilHeight);
68100
void WriteBlockInstantSendLocks(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected);
69101
void RemoveBlockInstantSendLocks(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected);
70102
bool KnownInstantSendLock(const uint256& islockHash) const;
103+
/**
104+
* Gets the number of IS Locks which have not been confirmed by a block
105+
* @return size_t value of the number of IS Locks not confirmed by a block
106+
*/
71107
size_t GetInstantSendLockCount() const;
72108

109+
/**
110+
* Gets a pointer to the IS Lock based on the hash
111+
* @param hash The hash of the IS Lock
112+
* @param use_cache Should we try using the cache first or not
113+
* @return A Pointer object to the IS Lock, returns nullptr if it doesn't exist
114+
*/
73115
CInstantSendLockPtr GetInstantSendLockByHash(const uint256& hash, bool use_cache = true) const;
116+
/**
117+
* Gets an IS Lock hash based on the txid the IS Lock is for
118+
* @param txid The txid which is being searched for
119+
* @return Returns the hash the IS Lock of the specified txid, returns uint256() if it doesn't exist
120+
*/
74121
uint256 GetInstantSendLockHashByTxid(const uint256& txid) const;
122+
/**
123+
* Gets an IS Lock pointer from the txid given
124+
* @param txid The txid for which the IS Lock Pointer is being returned
125+
* @return Returns the IS Lock Pointer associated with the txid, returns nullptr if it doesn't exist
126+
*/
75127
CInstantSendLockPtr GetInstantSendLockByTxid(const uint256& txid) const;
128+
/**
129+
* Gets an IS Lock pointer from an input given
130+
* @param outpoint Since all inputs are really just outpoints that are being spent
131+
* @return IS Lock Pointer associated with that input.
132+
*/
76133
CInstantSendLockPtr GetInstantSendLockByInput(const COutPoint& outpoint) const;
77134

135+
/**
136+
* Gets a vector of IS Lock hashes of the IS Locks which rely on or are children of the parent IS Lock
137+
* @param parent The hash of the parent IS Lock
138+
* @return Returns a vector of IS Lock hashes
139+
*/
78140
std::vector<uint256> GetInstantSendLocksByParent(const uint256& parent) const;
141+
/**
142+
* Called when a ChainLock invalidated a IS Lock, removes any chained/children IS Locks and the invalidated IS Lock
143+
* @param islockHash IS Lock hash which has been invalidated
144+
* @param txid Transaction id associated with the islockHash
145+
* @param nHeight height of the block which recieved a chainlock and invalidated the IS Lock
146+
* @return A vector of IS Lock hashes of all IS Locks removed
147+
*/
79148
std::vector<uint256> RemoveChainedInstantSendLocks(const uint256& islockHash, const uint256& txid, int nHeight);
80149
};
81150

0 commit comments

Comments
 (0)