aboutsummaryrefslogtreecommitdiff
path: root/src/model/k2v
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/k2v')
-rw-r--r--src/model/k2v/causality.rs5
-rw-r--r--src/model/k2v/item_table.rs4
-rw-r--r--src/model/k2v/seen.rs5
3 files changed, 8 insertions, 6 deletions
diff --git a/src/model/k2v/causality.rs b/src/model/k2v/causality.rs
index b1ec8035..c80ebd39 100644
--- a/src/model/k2v/causality.rs
+++ b/src/model/k2v/causality.rs
@@ -7,6 +7,7 @@
//! "causality token", is used in the API and must be sent along with
//! each write or delete operation to indicate the previously seen
//! versions that we want to overwrite or delete.
+use base64::prelude::*;
use std::collections::BTreeMap;
use std::convert::TryInto;
@@ -67,13 +68,13 @@ impl CausalContext {
bytes.extend(u64::to_be_bytes(i));
}
- base64::encode_config(bytes, base64::URL_SAFE_NO_PAD)
+ BASE64_URL_SAFE_NO_PAD.encode(bytes)
}
/// Parse from base64-encoded binary representation.
/// Returns None on error.
pub fn parse(s: &str) -> Option<Self> {
- let bytes = base64::decode_config(s, base64::URL_SAFE_NO_PAD).ok()?;
+ let bytes = BASE64_URL_SAFE_NO_PAD.decode(s).ok()?;
if bytes.len() % 16 != 8 || bytes.len() < 8 {
return None;
}
diff --git a/src/model/k2v/item_table.rs b/src/model/k2v/item_table.rs
index bc2b1aef..28646f37 100644
--- a/src/model/k2v/item_table.rs
+++ b/src/model/k2v/item_table.rs
@@ -176,9 +176,9 @@ impl Crdt for DvvsEntry {
impl PartitionKey for K2VItemPartition {
fn hash(&self) -> Hash {
- use blake2::{Blake2b, Digest};
+ use blake2::{Blake2b512, Digest};
- let mut hasher = Blake2b::new();
+ let mut hasher = Blake2b512::new();
hasher.update(self.bucket_id.as_slice());
hasher.update(self.partition_key.as_bytes());
let mut hash = [0u8; 32];
diff --git a/src/model/k2v/seen.rs b/src/model/k2v/seen.rs
index 314d0f9e..51098710 100644
--- a/src/model/k2v/seen.rs
+++ b/src/model/k2v/seen.rs
@@ -9,6 +9,7 @@
use std::collections::BTreeMap;
+use base64::prelude::*;
use serde::{Deserialize, Serialize};
use garage_util::data::Uuid;
@@ -78,12 +79,12 @@ impl RangeSeenMarker {
let bytes = nonversioned_encode(&self)?;
let bytes = zstd::stream::encode_all(&mut &bytes[..], zstd::DEFAULT_COMPRESSION_LEVEL)?;
- Ok(base64::encode(&bytes))
+ Ok(BASE64_STANDARD.encode(&bytes))
}
/// Decode from msgpack+zstd+b64 representation, returns None on error.
pub fn decode(s: &str) -> Option<Self> {
- let bytes = base64::decode(&s).ok()?;
+ let bytes = BASE64_STANDARD.decode(&s).ok()?;
let bytes = zstd::stream::decode_all(&mut &bytes[..]).ok()?;
nonversioned_decode(&bytes).ok()
}