Abort is used to cancel this transaction. This is a noop for read transactions, already aborted or commited transactions.
()
| 108 | // This is a noop for read transactions, |
| 109 | // already aborted or commited transactions. |
| 110 | func (txn *Txn) Abort() { |
| 111 | // Noop for a read transaction |
| 112 | if !txn.write { |
| 113 | return |
| 114 | } |
| 115 | |
| 116 | // Check if already aborted or committed |
| 117 | if txn.rootTxn == nil { |
| 118 | return |
| 119 | } |
| 120 | |
| 121 | // Clear the txn |
| 122 | txn.rootTxn = nil |
| 123 | txn.modified = nil |
| 124 | txn.changes = nil |
| 125 | |
| 126 | // Release the writer lock since this is invalid |
| 127 | txn.db.writer.Unlock() |
| 128 | } |
| 129 | |
| 130 | // Commit is used to finalize this transaction. |
| 131 | // This is a noop for read transactions, |
no outgoing calls