aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/membership.rs10
-rw-r--r--src/rpc/ring.rs2
2 files changed, 5 insertions, 7 deletions
diff --git a/src/rpc/membership.rs b/src/rpc/membership.rs
index 4872899b..2d3b37a2 100644
--- a/src/rpc/membership.rs
+++ b/src/rpc/membership.rs
@@ -1,5 +1,6 @@
use std::collections::HashMap;
use std::io::{Read, Write};
+use std::fmt::Write as FmtWrite;
use std::net::{IpAddr, SocketAddr};
use std::path::PathBuf;
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -10,7 +11,6 @@ use futures::future::join_all;
use futures::select;
use futures_util::future::*;
use serde::{Deserialize, Serialize};
-use sha2::{Digest, Sha256};
use tokio::prelude::*;
use tokio::sync::watch;
use tokio::sync::Mutex;
@@ -134,16 +134,14 @@ impl Status {
let mut nodes = self.nodes.iter().collect::<Vec<_>>();
nodes.sort_unstable_by_key(|(id, _status)| *id);
- let mut hasher = Sha256::new();
+ let mut nodes_txt = String::new();
debug!("Current set of pingable nodes: --");
for (id, status) in nodes {
debug!("{} {}", hex::encode(&id), status.addr);
- hasher.input(format!("{} {}\n", hex::encode(&id), status.addr));
+ writeln!(&mut nodes_txt, "{} {}", hex::encode(&id), status.addr).unwrap();
}
debug!("END --");
- self.hash
- .as_slice_mut()
- .copy_from_slice(&hasher.result()[..]);
+ self.hash = sha256sum(nodes_txt.as_bytes());
}
}
diff --git a/src/rpc/ring.rs b/src/rpc/ring.rs
index 1646afbf..1df0bb41 100644
--- a/src/rpc/ring.rs
+++ b/src/rpc/ring.rs
@@ -56,7 +56,7 @@ impl Ring {
let datacenter_idx = datacenters.iter().enumerate().find(|(_, dc)| *dc == datacenter).unwrap().0;
for i in 0..config.n_tokens {
- let location = hash(format!("{} {}", hex::encode(&id), i).as_bytes());
+ let location = sha256sum(format!("{} {}", hex::encode(&id), i).as_bytes());
new_ring.push(RingEntry {
location: location.into(),