summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Cargo.lock88
-rw-r--r--client/src/download.rs4
-rw-r--r--doc/protocol.md2
-rw-r--r--shared/Cargo.toml2
-rw-r--r--shared/src/store.rs7
6 files changed, 26 insertions, 79 deletions
diff --git a/.gitignore b/.gitignore
index ea8c4bf..2a8ca7e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-/target
+/target*
diff --git a/Cargo.lock b/Cargo.lock
index 2b1f2b2..b2e76e4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -336,19 +336,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2"
[[package]]
-name = "block"
-version = "0.1.6"
+name = "blake3"
+version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
+checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e"
+dependencies = [
+ "arrayref",
+ "arrayvec",
+ "cc",
+ "cfg-if",
+ "constant_time_eq",
+]
[[package]]
-name = "block-buffer"
-version = "0.11.0-rc.3"
+name = "block"
+version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3fd016a0ddc7cb13661bf5576073ce07330a693f8608a1320b4e20561cc12cdc"
-dependencies = [
- "hybrid-array",
-]
+checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "block2"
@@ -582,10 +586,10 @@ dependencies = [
]
[[package]]
-name = "const-oid"
-version = "0.10.0-rc.3"
+name = "constant_time_eq"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "68ff6be19477a1bd5441f382916a89bc2a0b2c35db6d41e0f6e8538bf6d6463f"
+checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
[[package]]
name = "core-foundation"
@@ -671,15 +675,6 @@ dependencies = [
]
[[package]]
-name = "cpufeatures"
-version = "0.2.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3"
-dependencies = [
- "libc",
-]
-
-[[package]]
name = "crc32fast"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -720,17 +715,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
-name = "crypto-common"
-version = "0.2.0-rc.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b0b8ce8218c97789f16356e7896b3714f26c2ee1079b79c0b7ae7064bb9089fa"
-dependencies = [
- "getrandom 0.2.15",
- "hybrid-array",
- "rand_core 0.6.4",
-]
-
-[[package]]
name = "cursor-icon"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -743,17 +727,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
[[package]]
-name = "digest"
-version = "0.11.0-pre.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf2e3d6615d99707295a9673e889bf363a04b2a466bd320c65a72536f7577379"
-dependencies = [
- "block-buffer",
- "const-oid",
- "crypto-common",
-]
-
-[[package]]
name = "dispatch"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1202,15 +1175,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
-name = "hybrid-array"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2d35805454dc9f8662a98d6d61886ffe26bd465f5960e0e55345c70d5c0d2a9"
-dependencies = [
- "typenum",
-]
-
-[[package]]
name = "image"
version = "0.25.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2460,17 +2424,6 @@ dependencies = [
]
[[package]]
-name = "sha2"
-version = "0.11.0-pre.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "540c0893cce56cdbcfebcec191ec8e0f470dd1889b6e7a0b503e310a94a168f5"
-dependencies = [
- "cfg-if",
- "cpufeatures",
- "digest",
-]
-
-[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2737,12 +2690,6 @@ dependencies = [
]
[[package]]
-name = "typenum"
-version = "1.17.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
-
-[[package]]
name = "unicode-ident"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3043,11 +2990,11 @@ version = "0.1.0"
dependencies = [
"anyhow",
"bincode",
+ "blake3",
"glam",
"log",
"rand 0.9.0-beta.1",
"redb",
- "sha2",
]
[[package]]
@@ -3061,6 +3008,7 @@ dependencies = [
"image",
"log",
"rand 0.9.0-beta.1",
+ "rayon",
"weareshared",
]
diff --git a/client/src/download.rs b/client/src/download.rs
index 2d61a53..4a47ad9 100644
--- a/client/src/download.rs
+++ b/client/src/download.rs
@@ -21,7 +21,7 @@ use std::{collections::HashSet, marker::PhantomData, sync::RwLock};
use weareshared::{
helper::ReadWrite,
packets::{Packet, Resource},
- store::{ResourceStore, sha256},
+ store::{ResourceStore, resource_hash},
};
pub struct Downloader {
@@ -69,7 +69,7 @@ impl Downloader {
let mut state = self.inner.write().unwrap();
match p {
Packet::RespondResource(d) => {
- let key = Resource(sha256(&d.0), PhantomData);
+ let key = Resource(resource_hash(&d.0), PhantomData);
state.store.set_raw(&d.0)?;
state.need.remove(&key);
state.pending.remove(&key);
diff --git a/doc/protocol.md b/doc/protocol.md
index 63355dd..7324637 100644
--- a/doc/protocol.md
+++ b/doc/protocol.md
@@ -34,5 +34,5 @@ encoded text.
## Resources
-Resources are reusable things. They are identified by the SHA-256 hash of their
+Resources are reusable things. They are identified by the BLAKE3 hash of their
serialized content. See [resources.md](./resources.md)
diff --git a/shared/Cargo.toml b/shared/Cargo.toml
index 8665019..394983a 100644
--- a/shared/Cargo.toml
+++ b/shared/Cargo.toml
@@ -8,6 +8,6 @@ anyhow = "1.0.95"
bincode = "1.3.3"
glam = { version = "0.29.2", features = ["serde"] }
redb = "2.4.0"
-sha2 = "0.11.0-pre.4"
log = "0.4.22"
rand = "0.9.0-beta.1"
+blake3 = "1.5.5"
diff --git a/shared/src/store.rs b/shared/src/store.rs
index 37e3ab1..673a40e 100644
--- a/shared/src/store.rs
+++ b/shared/src/store.rs
@@ -17,7 +17,6 @@
use crate::{helper::ReadWrite, packets::Resource};
use anyhow::Result;
use redb::{Database, TableDefinition};
-use sha2::{Digest, Sha256};
use std::{collections::HashMap, marker::PhantomData, path::Path, sync::Mutex};
const T_ENTRIES: TableDefinition<[u8; 32], &[u8]> = TableDefinition::new("e");
@@ -59,7 +58,7 @@ impl ResourceStore {
}
}
pub fn set_raw(&self, value: &[u8]) -> Result<Resource> {
- let key = Resource(sha256(value), PhantomData);
+ let key = Resource(resource_hash(value), PhantomData);
match self {
ResourceStore::Redb(database) => {
let txn = database.begin_write()?;
@@ -85,8 +84,8 @@ impl ResourceStore {
}
}
-pub fn sha256(x: &[u8]) -> [u8; 32] {
- let mut hasher = Sha256::new();
+pub fn resource_hash(x: &[u8]) -> [u8; 32] {
+ let mut hasher = blake3::Hasher::new();
hasher.update(x);
hasher.finalize().into()
}