@@ -58,24 +58,93 @@ class CInstantSendDb
58
58
59
59
void Upgrade ();
60
60
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
+ */
61
66
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
+ */
62
74
void RemoveInstantSendLock (CDBBatch& batch, const uint256& hash, CInstantSendLockPtr islock, bool keep_cache = true );
63
75
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
+ */
64
81
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
+ */
65
88
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
+ */
66
94
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
+ */
67
99
void RemoveArchivedInstantSendLocks (int nUntilHeight);
68
100
void WriteBlockInstantSendLocks (const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected);
69
101
void RemoveBlockInstantSendLocks (const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected);
70
102
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
+ */
71
107
size_t GetInstantSendLockCount () const ;
72
108
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
+ */
73
115
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
+ */
74
121
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
+ */
75
127
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
+ */
76
133
CInstantSendLockPtr GetInstantSendLockByInput (const COutPoint& outpoint) const ;
77
134
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
+ */
78
140
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
+ */
79
148
std::vector<uint256> RemoveChainedInstantSendLocks (const uint256& islockHash, const uint256& txid, int nHeight);
80
149
};
81
150
0 commit comments