File tree 2 files changed +15
-7
lines changed
2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 1
- use std:: fs:: { File , OpenOptions } ;
2
- use std:: ops:: { Deref , DerefMut } ;
3
- use std:: path:: Path ;
1
+ use std:: {
2
+ fs:: { File , OpenOptions } ,
3
+ ops:: { Deref , DerefMut } ,
4
+ path:: Path ,
5
+ } ;
4
6
5
7
use bytemuck:: Pod ;
6
8
use color_eyre:: eyre:: bail;
7
- use mmap_rs:: { MmapMut , MmapOptions } ;
9
+ use mmap_rs:: { MmapFlags , MmapMut , MmapOptions } ;
8
10
9
11
const META_SIZE : usize = std:: mem:: size_of :: < usize > ( ) ;
10
12
@@ -86,6 +88,7 @@ impl<T> MmapVec<T> {
86
88
let mmap = MmapOptions :: new ( byte_len)
87
89
. expect ( "cannot create memory map" )
88
90
. with_file ( & file, 0 )
91
+ . with_flags ( MmapFlags :: SHARED )
89
92
. map_mut ( )
90
93
. expect ( "cannot build memory map" ) ;
91
94
@@ -159,6 +162,7 @@ impl<T> MmapVec<T> {
159
162
MmapOptions :: new ( new_file_len)
160
163
. expect ( "cannot create memory map" )
161
164
. with_file ( & self . file , 0 )
165
+ . with_flags ( MmapFlags :: SHARED )
162
166
. map_mut ( )
163
167
. expect ( "cannot build memory map" ) ,
164
168
) ;
Original file line number Diff line number Diff line change 1
- use crate :: merkle_tree:: { Branch , Hasher , Proof } ;
2
1
use std:: {
3
2
fs:: OpenOptions ,
4
3
io:: Write ,
@@ -9,10 +8,12 @@ use std::{
9
8
sync:: { Arc , Mutex } ,
10
9
} ;
11
10
12
- use mmap_rs:: { MmapMut , MmapOptions } ;
11
+ use mmap_rs:: { MmapFlags , MmapMut , MmapOptions } ;
13
12
use rayon:: prelude:: * ;
14
13
use thiserror:: Error ;
15
14
15
+ use crate :: merkle_tree:: { Branch , Hasher , Proof } ;
16
+
16
17
pub trait VersionMarker { }
17
18
#[ derive( Debug ) ]
18
19
pub struct Canonical ;
@@ -1142,6 +1143,7 @@ impl<H: Hasher> MmapMutWrapper<H> {
1142
1143
MmapOptions :: new ( usize:: try_from ( buf_len as u64 ) . expect ( "file size truncated" ) )
1143
1144
. expect ( "cannot create memory map" )
1144
1145
. with_file ( & file, 0 )
1146
+ . with_flags ( MmapFlags :: SHARED )
1145
1147
. map_mut ( )
1146
1148
. expect ( "cannot build memory map" )
1147
1149
} ;
@@ -1188,6 +1190,7 @@ impl<H: Hasher> MmapMutWrapper<H> {
1188
1190
)
1189
1191
. expect ( "cannot create memory map" )
1190
1192
. with_file ( & file, 0 )
1193
+ . with_flags ( MmapFlags :: SHARED )
1191
1194
. map_mut ( )
1192
1195
. expect ( "cannot build memory map" )
1193
1196
} ;
@@ -1229,9 +1232,10 @@ pub enum DenseMMapError {
1229
1232
1230
1233
#[ cfg( test) ]
1231
1234
mod tests {
1235
+ use hex_literal:: hex;
1236
+
1232
1237
use super :: * ;
1233
1238
use crate :: merkle_tree:: { test:: Keccak256 , Hasher } ;
1234
- use hex_literal:: hex;
1235
1239
1236
1240
struct TestHasher ;
1237
1241
You can’t perform that action at this time.
0 commit comments