diff --git a/lib/src/dbs/channel.rs b/lib/src/dbs/channel.rs index 4a14cac3..e9a3034e 100644 --- a/lib/src/dbs/channel.rs +++ b/lib/src/dbs/channel.rs @@ -147,12 +147,16 @@ impl Table { }; if !res.is_empty() { // Get total results - let n = res.len() - 1; + let n = res.len(); + // Exit when settled + if n == 0 { + break; + } // Loop over results for (i, (k, v)) in res.into_iter().enumerate() { if ctx.is_ok() { // Ready the next - if i == n { + if n == i + 1 { nxt = Some(k.clone()); } // Parse the key-value diff --git a/lib/src/dbs/iterate.rs b/lib/src/dbs/iterate.rs index a4afa641..cfb92a69 100644 --- a/lib/src/dbs/iterate.rs +++ b/lib/src/dbs/iterate.rs @@ -144,12 +144,16 @@ impl Table { }; if !res.is_empty() { // Get total results - let n = res.len() - 1; + let n = res.len(); + // Exit when settled + if n == 0 { + break; + } // Loop over results for (i, (k, v)) in res.into_iter().enumerate() { if ctx.is_ok() { // Ready the next - if i == n { + if n == i + 1 { nxt = Some(k.clone()); } // Parse the key-value diff --git a/lib/src/kvs/tx.rs b/lib/src/kvs/tx.rs index 0569c620..2455bb9a 100644 --- a/lib/src/kvs/tx.rs +++ b/lib/src/kvs/tx.rs @@ -191,11 +191,15 @@ impl Transaction { } }; // Get total results - let n = res.len() - 1; + let n = res.len(); + // Exit when settled + if n == 0 { + break; + } // Loop over results for (i, (k, v)) in res.into_iter().enumerate() { // Ready the next - if i == n { + if n == i + 1 { nxt = Some(k.clone()); } // Delete @@ -234,11 +238,15 @@ impl Transaction { } }; // Get total results - let n = res.len() - 1; + let n = res.len(); + // Exit when settled + if n == 0 { + break; + } // Loop over results for (i, (k, _)) in res.into_iter().enumerate() { // Ready the next - if i == n { + if n == i + 1 { nxt = Some(k.clone()); } // Delete @@ -278,11 +286,15 @@ impl Transaction { } }; // Get total results - let n = res.len() - 1; + let n = res.len(); + // Exit when settled + if n == 0 { + break; + } // Loop over results for (i, (k, v)) in res.into_iter().enumerate() { // Ready the next - if i == n { + if n == i + 1 { nxt = Some(k.clone()); } // Delete @@ -321,11 +333,15 @@ impl Transaction { } }; // Get total results - let n = res.len() - 1; + let n = res.len(); + // Exit when settled + if n == 0 { + break; + } // Loop over results for (i, (k, _)) in res.into_iter().enumerate() { // Ready the next - if i == n { + if n == i + 1 { nxt = Some(k.clone()); } // Delete