Skip to content

Commit 6bc5984

Browse files
committed
Fixed the error spam
1 parent 9733092 commit 6bc5984

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/database/chunks.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use byteorder::LE;
22
use heed::types::{Bytes, U64};
33
use heed::Env;
44
use tokio::task::spawn_blocking;
5-
use tracing::{debug, warn};
5+
use tracing::{trace, warn};
66

77
use crate::database::Database;
88
use crate::utils::error::Error;
@@ -100,7 +100,7 @@ impl Database {
100100
tokio::task::spawn(async move {
101101
// Check cache
102102
if cache.contains_key(&key) {
103-
debug!("Chunk already exists in cache: {:X}", key);
103+
trace!("Chunk already exists in cache: {:X}", key);
104104
}
105105
// If not in cache then search in database
106106
else if let Ok(chunk) =
@@ -146,7 +146,7 @@ impl Database {
146146
/// ```
147147
pub async fn insert_chunk(&self, value: Chunk) -> Result<(), Error> {
148148
// Calculate key of this chunk
149-
// WARNING: This key wasn't supposed to include value.dimension in the tuple but it was different from the key used in persistent database most likely a bug.
149+
// WARNING: This key wasn't supposed to include value.dimension in the tuple, but it was different from the key used in persistent database most likely a bug.
150150
let key = hash((value.dimension.as_ref().unwrap(), value.x_pos, value.z_pos));
151151

152152
// Insert chunk into persistent database
@@ -238,8 +238,7 @@ impl Database {
238238
// Else check persistent database and load it into cache
239239
} else {
240240
let res = spawn_blocking(move || Self::get_chunk_from_database(&db, &key))
241-
.await
242-
.unwrap();
241+
.await?;
243242

244243
// WARNING: The previous logic was to order the chunk to be loaded into cache whether it existed or not.
245244
// This has been replaced by directly loading the queried chunk into cache
@@ -276,7 +275,7 @@ impl Database {
276275
/// ```
277276
pub async fn update_chunk(&self, value: Chunk) -> Result<(), Error> {
278277
// Calculate key of this chunk
279-
// WARNING: This key wasn't supposed to include value.dimension in the tuple but it was different from the key used in persistent database most likely a bug.
278+
// WARNING: This key wasn't supposed to include value.dimension in the tuple, but it was different from the key used in persistent database most likely a bug.
280279
let key = hash((value.dimension.as_ref().unwrap(), value.x_pos, value.z_pos));
281280

282281
// Insert new chunk state into persistent database

src/database/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::path::PathBuf;
99
use std::sync::Arc;
1010
use std::time::Duration;
1111
use tokio::fs;
12-
use tracing::{debug, info};
12+
use tracing::{debug, info, trace};
1313

1414
use crate::utils::config::get_global_config;
1515
use crate::utils::error::Error;
@@ -33,7 +33,11 @@ pub struct Database {
3333
fn evict_chunk(_key: Arc<u64>, value: Chunk, cause: RemovalCause) -> ListenerFuture {
3434
async move {
3535
if cause == RemovalCause::Expired {
36-
debug!("Evicting chunk: {}, {}", value.x_pos, value.z_pos);
36+
trace!(
37+
"Evicting chunk from cache: {}, {}",
38+
value.x_pos,
39+
value.z_pos
40+
);
3741
}
3842
}
3943
.boxed()

0 commit comments

Comments
 (0)