@@ -5,6 +5,7 @@ use std::{
5
5
} ;
6
6
7
7
use futures:: channel:: oneshot;
8
+ use tracing:: { info, warn} ;
8
9
9
10
use cuprate_database:: { ConcreteEnv , DbResult , Env , RuntimeError } ;
10
11
use cuprate_helper:: asynch:: InfallibleOneshotReceiver ;
@@ -150,10 +151,16 @@ fn database_writer<Req, Res>(
150
151
// add that much instead of the default 1GB.
151
152
// <https://github.com/monero-project/monero/blob/059028a30a8ae9752338a7897329fe8012a310d5/src/blockchain_db/lmdb/db_lmdb.cpp#L665-L695>
152
153
let old = env. current_map_size ( ) ;
153
- let new = env. resize_map ( None ) ;
154
+ let new = env. resize_map ( None ) . get ( ) ;
154
155
155
- // TODO: use tracing.
156
- println ! ( "resizing database memory map, old: {old}B, new: {new}B" ) ;
156
+ const fn bytes_to_megabytes ( bytes : usize ) -> usize {
157
+ bytes / 1_000_000
158
+ }
159
+
160
+ let old_mb = bytes_to_megabytes ( old) ;
161
+ let new_mb = bytes_to_megabytes ( new) ;
162
+
163
+ info ! ( "Resizing database memory map, old: {old_mb}MB, new: {new_mb}MB" ) ;
157
164
158
165
// Try handling the request again.
159
166
continue ' retry;
@@ -170,8 +177,7 @@ fn database_writer<Req, Res>(
170
177
171
178
// Send the response back, whether if it's an `Ok` or `Err`.
172
179
if let Err ( e) = response_sender. send ( response) {
173
- // TODO: use tracing.
174
- println ! ( "database writer failed to send response: {e:?}" ) ;
180
+ warn ! ( "Database writer failed to send response: {e:?}" ) ;
175
181
}
176
182
177
183
continue ' main;
0 commit comments