From ca57df132e5acf94a2774c315dda6976ad976786 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 26 Jan 2022 13:50:38 +0000 Subject: [PATCH] Ensure writable transactions work correctly --- src/kvs/file/mod.rs | 24 ++++++++++++------------ src/kvs/mem/mod.rs | 24 ++++++++++++------------ src/kvs/tikv/mod.rs | 24 ++++++++++++------------ 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/kvs/file/mod.rs b/src/kvs/file/mod.rs index ae5d6a8e..6709d453 100644 --- a/src/kvs/file/mod.rs +++ b/src/kvs/file/mod.rs @@ -44,7 +44,7 @@ impl<'a> Transaction<'a> { // Cancel a transaction pub fn cancel(&mut self) -> Result<(), Error> { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Mark this transaction as done @@ -57,11 +57,11 @@ impl<'a> Transaction<'a> { // Commit a transaction pub fn commit(&mut self) -> Result<(), Error> { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Mark this transaction as done @@ -77,11 +77,11 @@ impl<'a> Transaction<'a> { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Remove the key @@ -95,7 +95,7 @@ impl<'a> Transaction<'a> { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check the key @@ -109,7 +109,7 @@ impl<'a> Transaction<'a> { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Get the key @@ -124,11 +124,11 @@ impl<'a> Transaction<'a> { V: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Set the key @@ -143,11 +143,11 @@ impl<'a> Transaction<'a> { V: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Set the key @@ -161,7 +161,7 @@ impl<'a> Transaction<'a> { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Convert the range to bytes diff --git a/src/kvs/mem/mod.rs b/src/kvs/mem/mod.rs index 5b6ebc32..b2d76145 100644 --- a/src/kvs/mem/mod.rs +++ b/src/kvs/mem/mod.rs @@ -44,7 +44,7 @@ impl<'a> Transaction<'a> { // Cancel a transaction pub fn cancel(&mut self) -> Result<(), Error> { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Mark this transaction as done @@ -57,11 +57,11 @@ impl<'a> Transaction<'a> { // Commit a transaction pub fn commit(&mut self) -> Result<(), Error> { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Mark this transaction as done @@ -77,11 +77,11 @@ impl<'a> Transaction<'a> { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Remove the key @@ -95,7 +95,7 @@ impl<'a> Transaction<'a> { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check the key @@ -109,7 +109,7 @@ impl<'a> Transaction<'a> { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Get the key @@ -124,11 +124,11 @@ impl<'a> Transaction<'a> { V: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Set the key @@ -143,11 +143,11 @@ impl<'a> Transaction<'a> { V: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Set the key @@ -161,7 +161,7 @@ impl<'a> Transaction<'a> { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Convert the range to bytes diff --git a/src/kvs/tikv/mod.rs b/src/kvs/tikv/mod.rs index a3b9864b..95661046 100644 --- a/src/kvs/tikv/mod.rs +++ b/src/kvs/tikv/mod.rs @@ -56,7 +56,7 @@ impl Transaction { // Cancel a transaction pub async fn cancel(&mut self) -> Result<(), Error> { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Mark this transaction as done @@ -69,11 +69,11 @@ impl Transaction { // Commit a transaction pub async fn commit(&mut self) -> Result<(), Error> { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Mark this transaction as done @@ -89,11 +89,11 @@ impl Transaction { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Delete the key @@ -107,7 +107,7 @@ impl Transaction { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check the key @@ -121,7 +121,7 @@ impl Transaction { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Get the key @@ -136,11 +136,11 @@ impl Transaction { V: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Set the key @@ -155,11 +155,11 @@ impl Transaction { V: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Check to see if transaction is writable - if self.rw { + if self.rw == false { return Err(Error::TxReadonlyError); } // Set the key @@ -173,7 +173,7 @@ impl Transaction { K: Into, { // Check to see if transaction is closed - if self.ok { + if self.ok == true { return Err(Error::TxFinishedError); } // Convert the range to bytes